Re: [PHP] [ask] convert unknown Korean's string to readable string

[email protected] (Richard Quadling)
Newsgroups php.general
Message-ID <CAKUjMCV4zp703+EwpANh3z6sra-NSnDfh87Qs0o1LhkBaGDvCQ@mail.gmail.com>
On 18 April 2013 08:06, Morning Star <[email protected]> wrote:

> $string = \uc548\ub155\ud558\uc138\uc694


<?php
$string1 = '\uc548\ub155\ud558\uc138\uc694';
$string2 = preg_replace('/\\\u([0-9a-f]+)/', '&#x$1;', $string1);
$string3 = html_entity_decode($string2, ENT_COMPAT, 'UTF-8');
echo
    'Original : ', $string1, PHP_EOL,
    'Entities : ', $string2, PHP_EOL,
    'Decoded  : ', $string3, PHP_EOL,
    PHP_EOL;
?>

outputs (at least for me) ...

안녕하세요

Based upon
http://stackoverflow.com/questions/7274183/php-convert-unicode-to-character.


Hope this helps.

-- 
Richard Quadling
Twitter : @RQuadling
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.