Solved

How to convert a string to UTF-16

Posted on 2006-07-12
7
5,686 Views
Last Modified: 2012-06-21
Hi Everyone,

I wonder how I can convert a normal string to UTF-16 encoding? This should be done without using PHP's mb functions.

Thanks!

Let's say I have this string and want it to use in UTF-16:

$StringToConvert = 'ÜĞİŞÇÖé';

Thanks,

0
Comment
Question by:blacklord
  • 2
  • 2
7 Comments
 

Author Comment

by:blacklord
ID: 17090632
Sorry, characters are not displayed correct. Here is another example:

$StringToConvert = 'éêâ';
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17090808
Maybe like yhis:
$s = PDF_utf8_to_utf16(utf8_encode($s));
0
 

Author Comment

by:blacklord
ID: 17091844
Hello Terref,

What is PDF_utf8_to_utf16 function? Is it a standard function or does it require a PHP module?

0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17091902
It's not standard built-in, you're right. PHP has no built-in functions that can convert to UTF-16 (as far as I know).
You can find more info here:
http://nl2.php.net/manual/en/ref.pdf.php
http://www.pdflib.com/products/pdflib/index.html
0
 
LVL 14

Accepted Solution

by:
ThG earned 500 total points
ID: 17112784
@TeRReF: sorry but that information is not right.

PHP actually has a builtin module for charset conversions, but it is not compiled by default. Sometimes i have to upload it to the ftp and load it via dl("iconv.so")

$utf16 = iconv("iso-8859-1", "utf-16", $str);

of course you need to supply the right input charset, and you must know it in advance.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question