C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

UCS-2

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
wael
Guest





PostPosted: Thu Aug 14, 2003 6:41 pm    Post subject: UCS-2 Reply with quote



Hello,
i want return the encoded string for unicode char

by example
this code
wchar_t xx = 'A';
'A' should be retrned 00 65 as ucs-2 encoded charcter
(please check
http://www.unicode.org/charts/
i hope you will understand what i mean ,,


thank you for take time read this
wael ahmed

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Ron Natalie
Guest





PostPosted: Fri Aug 15, 2003 2:16 am    Post subject: Re: UCS-2 Reply with quote




"wael" <twaeltt (AT) hotmail (DOT) com> wrote

Quote:
Hello,
i want return the encoded string for unicode char

by example
this code
wchar_t xx = 'A';
'A' should be retrned 00 65 as ucs-2 encoded charcter
(please check
http://www.unicode.org/charts/
i hope you will understand what i mean ,,

Well assuming that wchar_t is, in fact a 16 bit unicode encoded character (non-portable
assumption):

#include <iostream>
using namespace std;
int main() {
wchar_t wc = L'A';
cout << hex << ((wc >> Cool&0xFF) << " " << (wc & 0xFF) << "n";
}



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Gianni Mariani
Guest





PostPosted: Sat Aug 16, 2003 3:50 pm    Post subject: Re: UCS-2 Reply with quote



Ron Natalie wrote:
Quote:
"wael" <twaeltt (AT) hotmail (DOT) com> wrote


Hello,
i want return the encoded string for unicode char

by example
this code
wchar_t xx = 'A';
'A' should be retrned 00 65 as ucs-2 encoded charcter
(please check
http://www.unicode.org/charts/
i hope you will understand what i mean ,,


Well assuming that wchar_t is, in fact a 16 bit unicode encoded character (non-portable
assumption):

#include <iostream
using namespace std;
int main() {
wchar_t wc = L'A';
cout << hex << ((wc >> Cool&0xFF) << " " << (wc & 0xFF) << "n";
}

BTW - UCS-2 is more or less dead. UTF-16 replaces it. You need to deal
with surrogate pairs to print the correct codepoint value for unicode.

Now this is WAY non portable because some implementations of wchar_t are
UCS-4 and some are UTF-16.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Andy Heninger
Guest





PostPosted: Mon Aug 25, 2003 9:13 am    Post subject: Re: UCS-2 Reply with quote


"Gianni Mariani" <gi2nospam (AT) mariani (DOT) ws> wrote

Quote:
Ron Natalie wrote:
"wael" <twaeltt (AT) hotmail (DOT) com> wrote

wchar_t wc = L'A';
cout << hex << ((wc >> Cool&0xFF) << " " << (wc & 0xFF) << "n";

BTW - UCS-2 is more or less dead. UTF-16 replaces it. You need to deal
with surrogate pairs to print the correct codepoint value for unicode.

Now this is WAY non portable because some implementations of wchar_t are
UCS-4 and some are UTF-16.

Even worse, there are still compilers around where wchar_t is not based on

Unicode at all. If portability really matters, the only way to get Unicode
character constants is with numeric constants. Ugh.

-- Andy Heninger
[email]heninger (AT) us (DOT) ibm.com[/email]


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.