[Pas2js] store escaped strings

Mattias Gaertner nc-gaertnma at netcologne.de
Tue May 15 17:18:52 CEST 2018


On Tue, 15 May 2018 15:42:55 +0200 (CEST)
Michael Van Canneyt <michael at freepascal.org> wrote:

>[...]
> > var
> >  compressed_UTF16: String;
> > begin
> >  compressed_UTF16 := '\u46C0\u4138\u19A0\u342A\u6056\u1020';
> >
> > the compiler will emit:
> >  $mod.compressed_UTF16 = "\\u46C0\\u4138\\u19A0\\u342A\\u6056\\u1020"
> >
> >
> > AFAIK, we can store escaped strings. All string variables are escaped by
> > default. The only way would be to store at the localStorage. 
> > Any idea?  
> 
> You must escape them pascal-style.
> 
>   compressed_UTF16 := #$46C0#$4138#$19A0#$342A#$6056#$1020;
> 
> But I'm not 100% sure what the compiler expects, UTF8 or UTF16.

Same as Delphi/FPC: Char number literals are read as UnicodeStrings -
UTF-16.

Mattias


More information about the Pas2js mailing list