Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • What about strings containing a mix of unicode characters and standard characters? Commented May 3, 2011 at 2:50
  • @Acorn the unicode \uABCD escape sequence will cover the full range of characters. Did you want the shortest possible escape sequence? Commented May 3, 2011 at 2:56
  • @Acorn I updated it to produce the shortest sequence it can, so chars whose ord(c) <= 255 will be encoded as \xAB form, even in unicode string. Commented May 3, 2011 at 3:01
  • @samplebias: Even better! (you forgot to change the output though) Commented May 3, 2011 at 3:03