Re: Simple string conversion from UCS2 to ISO8859-1

Liste des GroupesRevenir à cl c 
Sujet : Re: Simple string conversion from UCS2 to ISO8859-1
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 21. Feb 2025, 20:45:36
Autres entêtes
Organisation : None to speak of
Message-ID : <87bjuvm68v.fsf@nosuchdomain.example.com>
References : 1
User-Agent : Gnus/5.13 (Gnus v5.13)
pozz <pozzugno@gmail.com> writes:
I want to write a simple function that converts UCS2 string into ISO8859-1:
>
void ucs2_to_iso8859p1(char *ucs2, size_t size);
>
ucs2 is a string of type "00480065006C006C006F" for "Hello". I'm
passing size because ucs2 isn't null terminated.

Is the UCS-2 really represented as a sequence of ASCII hex digits?

In actual UCS-2, each character is 2 bytes.  The representation for
"Hello" would be 10 bytes, either "\0H\0e\0l\0l\0o" or
"H\0e\0l\0l\0o\0", depending on endianness.  (UCS-2 is a subset of
UTF-16; the latter uses longer sequences to represent characters
outside the Basic Multilingual Plane.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
8 Apr 26 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal