update page now

Voting

: min(eight, nine)?
(Example: nine)

The Note You're Voting On

josip at cubrad dot com
12 years ago
For my last project I needed to convert several CSV files from Windows-1250 to UTF-8, and after several days of searching around I found a function that is partially solved my problem, but it still has not transformed all the characters. So I made ​​this:

function w1250_to_utf8($text) {
    // map based on:
    // http://konfiguracja.c0.pl/iso02vscp1250en.html
    // http://konfiguracja.c0.pl/webpl/index_en.html#examp
    // http://www.htmlentities.com/html/entities/
    $map = array(
        chr(0x8A) => chr(0xA9),
        chr(0x8C) => chr(0xA6),
        chr(0x8D) => chr(0xAB),
        chr(0x8E) => chr(0xAE),
        chr(0x8F) => chr(0xAC),
        chr(0x9C) => chr(0xB6),
        chr(0x9D) => chr(0xBB),
        chr(0xA1) => chr(0xB7),
        chr(0xA5) => chr(0xA1),
        chr(0xBC) => chr(0xA5),
        chr(0x9F) => chr(0xBC),
        chr(0xB9) => chr(0xB1),
        chr(0x9A) => chr(0xB9),
        chr(0xBE) => chr(0xB5),
        chr(0x9E) => chr(0xBE),
        chr(0x80) => '€',
        chr(0x82) => '‚',
        chr(0x84) => '„',
        chr(0x85) => '…',
        chr(0x86) => '†',
        chr(0x87) => '‡',
        chr(0x89) => '‰',
        chr(0x8B) => '‹',
        chr(0x91) => '‘',
        chr(0x92) => '’',
        chr(0x93) => '“',
        chr(0x94) => '”',
        chr(0x95) => '•',
        chr(0x96) => '–',
        chr(0x97) => '—',
        chr(0x99) => '™',
        chr(0x9B) => '’',
        chr(0xA6) => '¦',
        chr(0xA9) => '©',
        chr(0xAB) => '«',
        chr(0xAE) => '®',
        chr(0xB1) => '±',
        chr(0xB5) => 'µ',
        chr(0xB6) => '¶',
        chr(0xB7) => '·',
        chr(0xBB) => '»',
    );
    return html_entity_decode(mb_convert_encoding(strtr($text, $map), 'UTF-8', 'ISO-8859-2'), ENT_QUOTES, 'UTF-8');
}

<< Back to user notes page

To Top