File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,7 @@ class HLL::Compiler does HLL::Backend::Default {
357
357
my str $ line := " " ;
358
358
my int $ lineno := 0 ;
359
359
my int $ char-found := -1 ;
360
+ my int $ nulls-found := 0 ;
360
361
361
362
until $ char-found != -1 {
362
363
$ line := nqp ::readlinechompfh($ new-handle );
@@ -368,6 +369,8 @@ class HLL::Compiler does HLL::Backend::Default {
368
369
if nqp ::ordat($ line , $ idx ) == 0x10fffd {
369
370
$ char-found := $ idx ;
370
371
last ;
372
+ } elsif nqp ::ordat($ line , $ idx ) == 0 {
373
+ $ nulls-found ++ ;
371
374
}
372
375
}
373
376
}
@@ -376,6 +379,9 @@ class HLL::Compiler does HLL::Backend::Default {
376
379
nqp ::sayfh(nqp ::getstderr(), " Error while reading from file: Invalid UTF-8 encountered on line $ lineno , character $ char-found" );
377
380
nqp ::sayfh(nqp ::getstderr(), $ line );
378
381
nqp ::sayfh(nqp ::getstderr(), nqp ::x (" " , $ char-found ) ~ " ^ here maybe?" );
382
+ if $ nulls-found > 2 {
383
+ nqp ::sayfh(nqp ::getstderr(), " Is the caret in the wrong position?\n We found $ nulls-found null bytes, which usually means utf16 or ucs16 encoding." );
384
+ }
379
385
380
386
return ;
381
387
}
You can’t perform that action at this time.
0 commit comments