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 write out a text file in C# with a code page other than UTF-8?

using System.IO; using System.Text; using (StreamWriter sw = new StreamWriter(File.Open(myfilename, FileMode.Create), Encoding.WhateverYouWant)) { sw.WriteLine(“my text…”); } An alternate way of getting your encoding: using System.IO; using System.Text; using (var sw = new StreamWriter(File.Open(@”c:\myfile.txt”, FileMode.CreateNew), Encoding.GetEncoding(“iso-8859-1”))) { sw.WriteLine(“my text…”); } Check out the docs for the StreamWriter constructor.

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

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

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

HTML encoding issues – “” character showing up instead of ” “

Somewhere in that mess, the non-breaking spaces from the HTML template (the  s) are encoding as ISO-8859-1 so that they show up incorrectly as an “” character That’d be encoding to UTF-8 then, not ISO-8859-1. The non-breaking space character is byte 0xA0 in ISO-8859-1; when encoded to UTF-8 it’d be 0xC2,0xA0, which, if you (incorrectly) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)