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.

The typical approach here would be to convert to base64:
http://msdn.microsoft.com/en-us/library/system.convert.tobase64string.aspx


> 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.

I don't know about this, but it seems appropriate for the chars to not
be converted. I would "guess" that you need to convert them manually,
because it's basically just an arbritrary encoding scheme, and I don't
see why encoding="ascii" should neccessitate that. That said, there's
probably some library or something that does it. Shouldn't be hard to
search ...

[...]


> Greg

-- 
silky

http://dnoondt.wordpress.com/

"Every morning when I wake up, I experience an exquisite joy -- the joy
of being this signature."

Reply via email to