Tag Archives: unicode

Replace unicode character

Questions: I am trying to replace a certain character in a string with another. They are quite obscure latin characters. I want to replace character (hex) 259 with 4d9, so I tried this: str_replace(“\x02\x59″,”\x04\xd9”,$string); This didn’t work. How do I go about this? **EDIT: Additional information. Thanks bobince, that has done the trick. Although, I… Read More »

How to reverse a Unicode string

Questions: It was hinted in a comment to an answer to this question that PHP can not reverse Unicode strings. As for Unicode, it works in PHP because most apps process it as binary. Yes, PHP is 8-bit clean. Try the equivalent of this in PHP: perl -Mutf8 -e ‘print scalar reverse(“ほげほげ”)’ You will get… Read More »

Strategy for supporting unicode & multi language in PHP5

Questions: I have heard that PHP6 will natively support unicode, which will hopefully make multi-language support much easier. However, PHP5 has pretty weak support for unicode and multi-language (i.e. just a bunch of specialized string functions). I was wondering what are your strategies to enable unicode and multi-languaage support in your PHP5 applications? Also, how… Read More »

'Reliable' SMS Unicode & GSM Encoding in PHP

Questions: (Updated a little) I’m not very experienced with internationalisation using PHP, it must be said, and a deal of searching didn’t really provide the answers I was looking for. I’m in need of working out a reliable way to convert only ‘relevant’ text to Unicode to send in an SMS message, using PHP (just… Read More »

PHP: How to create unicode filenames

Questions: I’m trying to create files with Unicode characters in there filenames. I don’t quite know what encoding I should use, or if it’s possible at all. I have this file, saved in latin1 encoding: $h = fopen(“unicode_♫.txt”, ‘w’); fclose($h); In UTF-8 this would decode as ‘unicode_♫.txt’. It writes it in the latin1 version to… Read More »

PHP function imagettftext() and unicode

Questions: I’m using the PHP function imagettftext() to convert text into a GIF image. The text I am converting has Unicode characters including Japanese. Everything works fine on my local machine (Ubuntu 7.10), but on my webhost server, the Japanese characters are mangled. What could be causing the difference? Everything should be encoded as UTF-8.… Read More »

python pandas read_excel returns UnicodeDecodeError on describe()

Questions: I love pandas, but I am having real problems with Unicode errors. read_excel() returns the dreaded Unicode error: import pandas as pd df=pd.read_excel(‘tmp.xlsx’,encoding=’utf-8′) df.describe() ————————————————————————— UnicodeDecodeError Traceback (most recent call last) … UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc2 in position 259: ordinal not in range(128) I figured out that the original Excel had… Read More »

Excel Function – Convert unicode to ascii

Questions: Is there any function in Excel (2010) which decode unicode to ascii text? One column in my sheet contains word/sentences in Portuguese. For Example: Esse Jean é feio né Should become Esse Jean é feio né é – This letter in the text is not Portuguese, is there any function to convert this to… Read More »