Using .NET how to convert ISO 8859-1 encoded text files that contain Latin-1 accented characters to UTF-8

You need to get the proper Encoding object. ASCII is just as it’s named: ASCII, meaning that it only supports 7-bit ASCII characters. If what you want to do is convert files, then this is likely easier than dealing with the byte arrays directly. using (System.IO.StreamReader reader = new System.IO.StreamReader(fileName, Encoding.GetEncoding(“iso-8859-1”))) { using (System.IO.StreamWriter writer … Read more

Jquery ignores encoding ISO-8859-1

Because I had the same problem, I’ll provide a solution that worked for me. Background: Microsoft Excel is too stupid to export a CSV-File in charset UTF-8: $.ajax({ url: ‘…’, contentType: ‘Content-type: text/plain; charset=iso-8859-1’, // This is the imporant part!!! beforeSend: function(jqXHR) { jqXHR.overrideMimeType(‘text/html;charset=iso-8859-1’); } });

Why does Java’s String.getBytes() uses “ISO-8859-1”

It is a bit complicated … Java tries to use the default character encoding to return bytes using String.getBytes(). The default charset is provided by the system file.encoding property. This is cached and there is no use in changing it via the System.setProperty(..) after the JVM starts. If the file.encoding property does not map to … Read more

Convert text value in SQL Server from UTF8 to ISO 8859-1

I have written a function to repair UTF-8 text that is stored in a varchar field. To check the fixed values you can use it like this: CREATE TABLE #Table1 (Column1 varchar(max)) INSERT #Table1 VALUES (‘Olá. Gostei do jogo. Quando “baixei” até achei que não iria curtir muito’) SELECT *, NewColumn1 = dbo.DecodeUTF8String(Column1) FROM Table1 … Read more

Converting UTF-8 to ISO-8859-1 in Java – how to keep it as single byte

If you’re dealing with character encodings other than UTF-16, you shouldn’t be using java.lang.String or the char primitive — you should only be using byte[] arrays or ByteBuffer objects. Then, you can use java.nio.charset.Charset to convert between encodings: Charset utf8charset = Charset.forName(“UTF-8”); Charset iso88591charset = Charset.forName(“ISO-8859-1”); ByteBuffer inputBuffer = ByteBuffer.wrap(new byte[]{(byte)0xC3, (byte)0xA2}); // decode UTF-8 … Read more

Convert latin1 characters on a UTF8 table into UTF8

From what you describe, it seems you have UTF-8 data that was originally stored as Latin-1 and then not converted correctly to UTF-8. The data is recoverable; you’ll need a MySQL function like convert(cast(convert(name using latin1) as binary) using utf8) It’s possible that you may need to omit the inner conversion, depending on how the … Read more

Convert utf8-characters to iso-88591 and back in PHP

Have a look at iconv() or mb_convert_encoding(). Just by the way: why don’t utf8_encode() and utf8_decode() work for you? utf8_decode — Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1 utf8_encode — Encodes an ISO-8859-1 string to UTF-8 So essentially $utf8 = ‘ÄÖÜ’; // file must be UTF-8 encoded $iso88591_1 = utf8_decode($utf8); … Read more

How do I convert between ISO-8859-1 and UTF-8 in Java?

In general, you can’t do this. UTF-8 is capable of encoding any Unicode code point. ISO-8859-1 can handle only a tiny fraction of them. So, transcoding from ISO-8859-1 to UTF-8 is no problem. Going backwards from UTF-8 to ISO-8859-1 will cause “replacement characters” (�) to appear in your text when unsupported characters are found. To … Read more