Re: [ask] convert unknown format Japanese string to readable string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i want to try something else. korean. i got no luck when I tried with
Korean. 'UCS-2BE' to 'UTF-8' encoding conversion didn't work. i also
tried with ISO-2022-KR and EUC-KR to 'UTF-8' , but no luck either.


How can I do that?

Regards,

Marco

On Fri, Apr 12, 2013 at 8:49 AM, Morning Star
<morning.star.crew@xxxxxxxxx> wrote:
> It works!
> Thanks, Koyama! :)
>
> On Thu, Apr 11, 2013 at 8:54 AM, KOYAMA Tetsuji <koyama@xxxxxxxx> wrote:
>> Hi,
>>
>> On Thu, Apr 11, 2013 at 5:39 PM, Morning Star
>> <morning.star.crew@xxxxxxxxx> wrote:
>>> Hi guys,
>>>
>>> i have a string like this:
>>> $string = \u3053\u3093\u306b\u3061\u306f\u30ef\u30fc\u30c9
>>> (Japanese words that say "hello world" in English)
>>> How can I convert that $string to Japanese character?
>>> It should be こんにちは世界
>>
>> I found tips in the stackoverflow.
>>
>> http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha
>>
>> I try it.
>>
>> <?php
>> $str = "\u3053\u3093\u306b\u3061\u306f\u30ef\u30fc\u30c9";
>>
>> function replace_unicode_escape_sequence($match) {
>>     return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
>> }
>> $str = preg_replace_callback('/\\\\u([0-9a-f]{4})/i',
>>                              'replace_unicode_escape_sequence', $str);
>> var_dump($str);
>>
>>
>> Then it displays:
>> string(24) "こんにちはワード"
>>
>> regards,
>>
>> --
>>     KOYAMA Tetsuji
>>     koyama@xxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux