?
Solved

How to convert a string to UTF-16

Posted on 2006-07-12
7
Medium Priority
?
5,751 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 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