PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > convert byte array to unicode?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
convert byte array to unicode?

Réponse
 
LinkBack Outils de la discussion
Vieux 06/11/2007, 00h22   #1
Sergei Shelukhin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut convert byte array to unicode?

Hi. I receive a byte array that contains utf-16 string (with a lot of
\0 characters ) from a legacy system that holds some data that is
changed elsewhere. How do I convert it to an actual utf-16 string for
my app's purposes? I am using php 5.

  Réponse avec citation
Vieux 06/11/2007, 00h37   #2
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: convert byte array to unicode?

On Nov 5, 5:22 pm, Sergei Shelukhin <realg...@gmail.com> wrote:
> Hi. I receive a byte array that contains utf-16 string (with a lot of
> \0 characters ) from a legacy system that holds some data that is
> changed elsewhere. How do I convert it to an actual utf-16 string for
> my app's purposes? I am using php 5.


After outputting the byte order mark (either chr(0xFE).chr(0xFF) or
chr(0xFF).chr(0xFE)) you'd just output the string as usual. If you're
going to output this to HTML, you'd need to specify the charset. eg.

header('Content-Type: text/html; charset=UTF-16');

  Réponse avec citation
Vieux 06/11/2007, 23h26   #3
Sergei Shelukhin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: convert byte array to unicode?

On Nov 6, 2:37 am, yawnmoth <terra1...@yahoo.com> wrote:
> On Nov 5, 5:22 pm, Sergei Shelukhin <realg...@gmail.com> wrote:
>
> > Hi. I receive a byte array that contains utf-16 string (with a lot of
> > \0 characters ) from a legacy system that holds some data that is
> > changed elsewhere. How do I convert it to an actual utf-16 string for
> > my app's purposes? I am using php 5.

>
> After outputting the byte order mark (either chr(0xFE).chr(0xFF) or
> chr(0xFF).chr(0xFE)) you'd just output the string as usual. If you're
> going to output this to HTML, you'd need to specify the charset. eg.
>
> header('Content-Type: text/html; charset=UTF-16');


What about passing it to linux command line application (script
really)?

  Réponse avec citation
Vieux 07/11/2007, 15h11   #4
AnrDaemon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: convert byte array to unicode?

Greetings, Sergei Shelukhin.
In reply to Your message dated Wednesday, November 7, 2007, 01:26:55,

>> > Hi. I receive a byte array that contains utf-16 string (with a lot of
>> > \0 characters ) from a legacy system that holds some data that is
>> > changed elsewhere. How do I convert it to an actual utf-16 string for
>> > my app's purposes? I am using php 5.

>>
>> After outputting the byte order mark (either chr(0xFE).chr(0xFF) or
>> chr(0xFF).chr(0xFE)) you'd just output the string as usual. If you're
>> going to output this to HTML, you'd need to specify the charset. eg.
>>
>> header('Content-Type: text/html; charset=UTF-16');


> What about passing it to linux command line application (script
> really)?


Passing what? UTF-16 string? Guess it's tricky if not impossible.
Try converting it to UTF-8 (using iconv i.e.)


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h52.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08551 seconds with 12 queries