[PHP] [ask] convert unknown format Japanese string to readable string
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 こんにちは世界 my regards, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [ask] convert unknown format Japanese string to readable string
It works! Thanks, Koyama! :) On Thu, Apr 11, 2013 at 8:54 AM, KOYAMA Tetsuji wrote: > Hi, > > On Thu, Apr 11, 2013 at 5:39 PM, Morning Star > 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. > > $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 > koy...@hoge.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [ask] convert unknown format Japanese string to readable string
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 wrote: > It works! > Thanks, Koyama! :) > > On Thu, Apr 11, 2013 at 8:54 AM, KOYAMA Tetsuji wrote: >> Hi, >> >> On Thu, Apr 11, 2013 at 5:39 PM, Morning Star >> 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. >> >> > $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 >> koy...@hoge.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [ask] convert unknown format Japanese string to readable string
Hi guys, Does anyone have an idea how to solve that? convert from Korea's encoding to utf8's encoding. Regards, Marco On Sun, Apr 14, 2013 at 6:29 AM, Morning Star wrote: > 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 > wrote: >> It works! >> Thanks, Koyama! :) >> >> On Thu, Apr 11, 2013 at 8:54 AM, KOYAMA Tetsuji wrote: >>> Hi, >>> >>> On Thu, Apr 11, 2013 at 5:39 PM, Morning Star >>> 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. >>> >>> >> $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 >>> koy...@hoge.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [ask] convert unknown Korean's string to readable string
Hi guys, i have a string like this: $string = \uc548\ub155\ud558\uc138\uc694 (Korean words that say "hello world" in English). 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. It should be 안녕하세요! How can I convert that $string to Korean's character? my regards, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [ask] convert unknown Korean's string to readable string
Thanks, Richard. It works in xterm, but it doesn't work in KDE konsole. i don't know how to figure it out. help me Best regards, Marco On Mon, Apr 22, 2013 at 9:43 AM, Richard Quadling wrote: > > On 18 April 2013 08:06, Morning Star wrote: >> >> $string = \uc548\ub155\ud558\uc138\uc694 > > > $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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [ask] convert unknown Korean's string to readable string
Hi Richard, i am sure my KDE konsole is set to UTF-8. fortunately, i got a answer from the Debian mailing list. someone told me to verify if i had installed the ttf-baekmuk (Korean's font) or not. i see that it is not install yet. i just installed it and then i am able to view the Korean's font. Thanks anyway. Best regards, Marco On Tue, Apr 30, 2013 at 2:40 PM, Richard Quadling wrote: > > > > On 29 April 2013 20:38, Morning Star wrote: >> >> Thanks, Richard. It works in xterm, but it doesn't work in KDE konsole. >> i don't know how to figure it out. help me >> >> Best regards, >> >> Marco >> >> On Mon, Apr 22, 2013 at 9:43 AM, Richard Quadling >> wrote: >> > >> > On 18 April 2013 08:06, Morning Star >> > wrote: >> >> >> >> $string = \uc548\ub155\ud558\uc138\uc694 >> > >> > >> > > > $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 >> > > > > > Can you show exactly what is produced? > > I'm guessing your KDE console is not set to UTF-8. > > I'm on a Mac, so I'm not able to help with that other than maybe > http://www.linuxquestions.org/questions/linux-software-2/kde-and-utf8-276033/ > > > -- > Richard Quadling > Twitter : @RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php