1

When compiling to javaScript the dart2js compiler converts the string to an escaped utf format

\u043d\u041d...

I am not sure why his is done (the original file contains text strings that are in cyrillic, but the system (and hopefully DartEditor) use UTF).

Other compilers (like Closure or TypeScript) leave it as it is.

I am wondering if someone can explain:

  1. Why it is done in this way
  2. What is the significance of this
  3. Is there a way to turn this off

Thanks.

2 Answers 2

1

When dart2js reads a string it decodes that string. For example if your string contained a \n it decodes it into a new line character. When dart2js writes the string out, it does needs to encode the strings again. For simplicity dart2js simply encodes everything that is not ASCII.

Please file a bug report, and we will have a look to see if it's easy to fix.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, thanks, submitted a report. code.google.com/p/dart/issues/detail?id=22145
0

In the browser (at least in V8 in Chrome) a string is represented with 1 byte per character if there are no characters outside the range of 0-255. If there is just one character outside that range, then the string is represented as 2 bytes per character. So for a small number of Cyrillic characters this can be a more compact representation in terms of browser memory.

However I'm not aware of any measurements, and there may be reasons why this theoretical space saving does not work in practice.

1 Comment

The whole string is Cyrillic chars, so I would expect some heuristics to be at play but...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.