Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1170

Decoding Base64 string doesn't translate special chars

$
0
0

I have an XML file encoded as Base64, this file has embeded images in it.

My problem is when I try to decode it:

String sample is here

Here is my code:

UTF8 Version: This one can be decoded and loaded into XML but special chars don't decode properly (á,é,í,ó,ú,ñ,Ñ) all are decoded as ? symbol.

    public XmlDocument GetXmlDocument(string Base64Text)    {        string DeCoded = string.Empty;        XmlDocument Datos = new XmlDocument();        byte[] Base64 = Convert.FromBase64String(Base64Text);        DeCoded = Encoding.UTF8.GetString(Base64);        Datos.LoadXml(DeCoded);         return Datos;    }

UTF7 Version: This one can be decoded and special chars are all decoded properly. If Has images can't be loaded to XML Document due embedded images doesn't decode properly.

    public XmlDocument GetXmlDocument(string Base64Text)    {        string DeCoded = string.Empty;        XmlDocument Datos = new XmlDocument();        byte[] Base64 = Convert.FromBase64String(Base64Text);        DeCoded = Encoding.UTF7.GetString(Base64);        Datos.LoadXml(DeCoded);         return Datos;    }

EDIT 1: My encoded Base64 string came from VFP app it was encoded usingVFP SintaxSTRCONV(lcImage, 6)

In VFP help it says: Converts character expressions between single-byte, double-byte, UNICODE, and locale-specific representations.

And 6 means:

6   Converts UNICODE (wide characters) to double-byte characters. 

I'm trying with UTF7 and UTF8, just testing which one could translate my string.

I just need my original XML with it's embedded images in .NET, If this is impossible with standard functions, How can I catch and translate ? symbol s to readable chars?


Viewing all articles
Browse latest Browse all 1170

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>