I inherited an old Ubuntu 6.10 server running php 5.1.6 which is using sybase to connect to MSSQL. A user submitted some text containing an en-dash and crashed one of my script. It turns out sybase doesn't like UTF-8 characters such as en-dash or é. Future searches in the database will also not like these characters. To remedy this, I want to convert characters such as en-dash to hyphen, é to e, etc... I did a little research into transliteration.

The solution I came up with was to use PHP's iconv function to transliterate from UTF-8 to ASCII. It works fine on my development machine (Ubuntu 12.04) but not on my old production server (Ubuntu 6.10). After some debugging, I think I've tracked down my problem to the version of iconv.

echo café > test.txt
iconv --from-code=UTF8 --to-code=ASCII//TRANSLIT test.txt

result on 6.10: caf?
result on 12.04: cafe

iconv --version
result on 6.10: iconv (GNU libc) 2.4
result on 12.04: iconv (Ubuntu EGLIBC 2.15-0ubuntu10) 2.15

locale on both systems returns "en_US.UTF-8"

I think I need to upgrade the production machine's iconv library but I'm not quite sure how to go about this.

  • 6.10 has been EOL for 4 years. – jordanm Apr 18 '13 at 19:54
  • I am painfully aware. This is a production server that has been hosting our company intranet. I'm currently in the process of updating the codebase (mostly PHP) to run on something more current. – Pete Apr 18 '13 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.