Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:38:31+00:00 2026-05-20T22:38:31+00:00

trace(escape(д)); will print %D0%B4, the correct URL encoding for this character (Cyrillic equivalent of

  • 0
trace(escape("д"));

will print “%D0%B4”, the correct URL encoding for this character (Cyrillic equivalent of “A”).

However, if I were to do..

myTextArea.htmlText += unescape("%D0%B4");

What gets printed is:

д

which is of course incorrect. Simply tracing the above unescape returns the correct Cyrillic character, though! For this texarea, escaping “д” returns its unicode code-point “%u0434”.

I’m not sure what exactly is happening to mess this up, but…

UTF-16 д in web encoding is: %FE%FF%00%D0%00%B4

Whereas

UTF-16 д in web encoding is: %00%D0%00%B4

So it’s padding this value with something at the beginning. Why would a trace provide different text than a print to an (empty) textarea? What’s goin’ on?

The textarea in question has no weird encoding properties attached to it, if that sort of thing is even possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:38:32+00:00Added an answer on May 20, 2026 at 10:38 pm

    The problem is unescape (escape could also be a problem, but it’s not the culprit in this case). These functions are not multibyte aware. What escape does is this: it takes a byte in the input string and returns its hex representation with a % prepended. unescape does the opposite. The key point here is that they work with bytes, not characters.

    What you want is encodeURIComponent / decodeURIComponent. Both use utf-8 as the string encoding scheme (the encoding using by flash everywhere). Note that it’s not utf-16 (which you shouldn’t care about as long as flash is concerned).

    encodeURIComponent("д"); //%D0%B4
    decodeURIComponent("%D0%B4"); // д
    

    Now, if you want to dig a bit deeper, here’s what’s going on (this assumes a basic knowledge of how utf-8 works).

    escape("д")
    

    This returns

    %D0%B4
    

    Why?

    “д” is treated by flash as utf-8. The codepoint for this character is 0x0434.

    In binary:

    0000 0100 0011 0100
    

    It fits in two utf-8 bytes, so it’s encoded thus (where e means encoding bit, and p means payload bit):

    1101 0000 1011 0100
    eeep pppp eepp pppp 
    

    Converting it to hex, we get:

    0xd0  0xb4
    

    So, 0xd0,0xb4 is a utf-8 encoded “д”.

    This is fed to escape. escape sees two bytes, and gives you:

    %d0%b4
    

    Now, you pass this to unescape. But unescape is a little bit brain-dead, so it thinks one byte is one and the same thing as one char, always. As far as unescape is concerned, you have two bytes, hence, you have two chars. If you look up the code-points for 0xd0 and 0xb4, you’ll see this:

    0xd0 -> Ð
    0xb4 -> ´
    

    So, unescape returns a string consisting of two chars, Ð and ´ (instead of figuring out that the two bytes it got where actually just one char, utf-8 encoded). Then, when you assign the text property, you are not really passing д´ butд`, and this is what you see in the text area.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The TRACE macro can be used to output diagnostic messages to the debugger when
We'd like a trace in our application logs of these exceptions - by default
How do you trace/profile your .NET applications? The MSDN online help mentions Visual Studio
I have a trace setup for SQL Server Profiler to monitor SQL that is
We are trying to trace the time a windows default printer was changed and
I am trying to trace a deadlock that is occurring in our SQL 2005
any generic way to trace/log values of all local variables when an exception occurs
My application uses the Trace object to log information. The information is captured in
I want to use SQL Profiler to trace the queries executed agains my database,
I need to produce a calculation trace file containing tabular data showing intermediate results.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.