Browse Source

pas2js: skip invalid surrogate

mattias 1 year ago
parent
commit
bb817db47a
1 changed files with 3 additions and 2 deletions
  1. 3 2
      packages/pastojs/src/fppas2js.pp

+ 3 - 2
packages/pastojs/src/fppas2js.pp

@@ -6780,7 +6780,7 @@ var
         else break;
         else break;
         end;
         end;
         if Result>$10ffff then
         if Result>$10ffff then
-          RaiseNotYetImplemented(20170207164657,El,'maximum codepoint is $10ffff');
+          Err(20170207164657);
         inc(p);
         inc(p);
         end;
         end;
       if p=StartP then
       if p=StartP then
@@ -6859,7 +6859,8 @@ begin
         if (j>=$DC00) and (j<$DFFF) then
         if (j>=$DC00) and (j<$DFFF) then
           Result:=Result+CodePointToJSString((i and $3FF) shl 10 + (j and $3ff) + $10000)
           Result:=Result+CodePointToJSString((i and $3FF) shl 10 + (j and $3ff) + $10000)
         else
         else
-          Err(20231017120034);
+          // invalid surrogate -> write as two \u
+          Result:=Result+CodePointToJSString(i)+CodePointToJSString(j)
         end
         end
       else
       else
         Result:=Result+CodePointToJSString(i);
         Result:=Result+CodePointToJSString(i);