Using Reflector to search string constants containing \u finds System.Web.Script.Serialization.JavaScriptString.QuoteString, but that is a Shared Friend function in a Private type in System.Web.Extensions for 3.5. It also finds a couple of similar implementations in the Microsoft namespaces (both semi-public and private).
However in 4.0 the above is replaced by System.Web.HttpUtility.JavaScriptStringEncode in System.Web.dll and that is Public Shared, and definitely useable outside a web context. -- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.) 2010/11/5 Greg Keogh <[email protected]>: > Folks, I have a pair of utility methods that I wrote in Framework 1.0 that > "escapes" and "unescapes" non-ASCII strings so I can roundtrip them via > ASCII. So the string "ABC123ΑΒΓ" (last 3 chars are Greek) becomes > "ABC123\u0391\u0392\u0393" and I can later reverse it. This ancient manual > code must be redundant now. Is there a way of doing this in the FCL now? I > can't quickly find one. > > > > Likewise, I'd like to be able to roundtrip arbitrary Unicode string via > encoding="ascii" XML with high characters converted to &# entities. I can't > find an automatic way of doing this either. If I save an XDocument in an > ASCII encoded TextWriter the high characters turn into question marks. > > > > If I use utf-8 XML then it's okay as you can see the CE91CE92CE93 encoding > in the file. > > > > Greg -- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.)
