[Pas2js] store escaped strings

Michael Van Canneyt michael at freepascal.org
Tue May 15 15:42:55 CEST 2018



On Tue, 15 May 2018, warleyalex via Pas2js 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.

Michael.


More information about the Pas2js mailing list