473,698 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unicode (UCS-2 encoded)

hello all,
i want convert w_char to UCS2 encoded (0041) this is a char encoded UCS2
please look at this
http://www.unicode.org/charts/
http://www.unicode.org/

every language has a chart
bye example
char 'A' = 0041--> (UCS encoded)

char 'any other language' = 0628 (this is in differ language)
i hope you uderstand what i mean

--
thank you for take time read this
best regards
wael ahmed
Jul 19 '05 #1
8 12786
Do you mean that you want to convert locale specific strings like ASCII,
utf8, big5, etc into unicode UCS2 two byte entities, and then store them in
a wchar_t?

When porting a web browser, we had a type tChar16 to put unicode into; it's
worthwhile using typedefs anyway, even though C++ has wchar_t. We wrote our
own language conversion libraries, it depends what you want to do. It's
probably not so much of a C++ question. Look up internationaliz ation on the
web, in relation to C++
Jul 19 '05 #2
"Jason" <@> wrote in message news:<3f468dcd@ shknews01>...
Do you mean that you want to convert locale specific strings like ASCII,
utf8, big5, etc into unicode UCS2 two byte entities, and then store them in
a wchar_t?

When porting a web browser, we had a type tChar16 to put unicode into; it's
worthwhile using typedefs anyway, even though C++ has wchar_t. We wrote our
own language conversion libraries, it depends what you want to do. It's
probably not so much of a C++ question. Look up internationaliz ation on the
web, in relation to C++

i have wchar_t charcter
suppose it is (16 bit) and like this

wchar_t ch = L'A';
//char A encoded UCS-2 is 0041
how do i get ch in 2 bytes UCS encoded ??
some data stored in data base UCS-2
0041 0065 etc ... 0628 0627 ....
thank you for take time read this
Jul 19 '05 #3

"wael" <tw*****@hotmai l.com> wrote in message
news:f7******** *************** **@posting.goog le.com...
"Jason" <@> wrote in message news:<3f468dcd@ shknews01>...
Do you mean that you want to convert locale specific strings like ASCII,
utf8, big5, etc into unicode UCS2 two byte entities, and then store them in a wchar_t?

When porting a web browser, we had a type tChar16 to put unicode into; it's worthwhile using typedefs anyway, even though C++ has wchar_t. We wrote our own language conversion libraries, it depends what you want to do. It's
probably not so much of a C++ question. Look up internationaliz ation on the web, in relation to C++

i have wchar_t charcter
suppose it is (16 bit) and like this

wchar_t ch = L'A';
//char A encoded UCS-2 is 0041
how do i get ch in 2 bytes UCS encoded ??
some data stored in data base UCS-2
0041 0065 etc ... 0628 0627 ....
thank you for take time read this


Like this?

wchar_t ch = L'A';
char bytes[2];
bytes[0] = ch/256; // byte[0] == 0x00
bytes[1] = ch%256; // byte[1] == 0x41

Still not completely clear what you are trying to do.

john
Jul 19 '05 #4
I am afraid I don't understand the question either. Perhaps you can tell us
what data your reading, and if it's in Unicode or ASCII and what you want to
do with it. Instead of talking about wchar_t's and UCS-2 straight away.
Jul 19 '05 #5

"wael" <tw*****@hotmai l.com> wrote in message
news:f7******** *************** ***@posting.goo gle.com...
"John Harrison" <jo************ *@hotmail.com> wrote in message

news:<bi******* *****@ID-196037.news.uni-berlin.de>...
"wael" <tw*****@hotmai l.com> wrote in message
news:f7******** *************** **@posting.goog le.com...
"Jason" <@> wrote in message news:<3f468dcd@ shknews01>...
> Do you mean that you want to convert locale specific strings like ASCII, > utf8, big5, etc into unicode UCS2 two byte entities, and then store
them in
> a wchar_t?
>


Like this?

wchar_t ch = L'A';
char bytes[2];
bytes[0] = ch/256; // byte[0] == 0x00
bytes[1] = ch%256; // byte[1] == 0x41

Still not completely clear what you are trying to do.

john


thank you for help ,
let me be more clear:-
1- i receive text from ascii socket like this ( i will assume it is on
{0041 , 0628 , 0627 , 0042}
each 4 chars is UCS-2 encoded hex as defined in
http://www.unicode.org/charts/
00 prifx for english 41 char as defined in chart
http://www.unicode.org/charts/PDF/U0000.pdf
06 prifx for arabic 28 is char as defined in chart
http://www.unicode.org/charts/PDF/U0600.pdf
also i receive data for other languages like greek

i want convert incoming string to wchar_t and from wchar_t to send it
by socket


OK, try again, perhaps like this?

ascii_data is your string of unicode numbers seperated by commas and with a
leading { and trailing }. I.e. what you read from the socket. At the end
unicode_data is a wide string of Unicode characters, you can write that to
your other socket.

#include <algorithm>
#include <istream>
#include <sstream>
#include <string>

int main()
{
std::string ascii_data = "{0041 , 0628 , 0627 , 0042}";
// remove leading and trailing {}
ascii_data.eras e(ascii_data.be gin());
ascii_data.eras e(ascii_data.en d() - 1);
// replace commas with spaces
std::replace(as cii_data.begin( ), ascii_data.end( ), ',', ' ');
// use string as stream
std::istringstr eam str(ascii_data) ;
// read hex numbers from stream
std::wstring unicode_data;
unsigned char_value;
while (str >> std::hex >> char_value)
{
unicode_data.pu sh_back(static_ cast<wchar_t>(c har_value));
}
}

john
Jul 19 '05 #6

"wael" <tw*****@hotmai l.com> wrote in message
news:f7******** *************** **@posting.goog le.com...
sorry ,
//bytes order
this was by mistake
//i am sorry if i can not let you understand may be for my bad language
i try encode wchar according 'The Unicode Standard and ISO/IEC 10646'
this is the format which i need
please look at:
Figure 1-1. Wide ASCII
http://www.unicode.org/book/uc20ch1.html
the picture display how chars look like in binary format
You will find 'A' is = '0000 0000 0100 0001' = (in hex) '0 0 4 1'
Other char down (arabic char) = '0000 0110 0011 0011' = in hex '0 6 3 3'
the problem is if i try get the binary string of this arabic char
it is '0000 0000 1101 0011' which != '0000 0110 0011 0011'
for that i must convert '0000 0000 1101 0011' to ISO/IEC 10646'

sorry for distrub you john
and thank you for try help me

thanks


Wael, at last I think I understand you!

You have characters encoded in one character set and you want to convert
them to Unicode. Do you know which character set you have currently? I think
there are two commonly used character sets for Arabic, one is IS0-8859-6,
the other is CP1256 Do you know which you have?

Whatever you have it should just a be a simple matter of setting up a table
to convert between them.

Here is a table that converts CP1256 to Unicode

http://www.unicode.org/Public/MAPPIN...OWS/CP1256.TXT

and here's a table that converts ISO-8859-6 to Unicode

http://www.unicode.org/Public/MAPPIN...859/8859-6.TXT

Hope this helps.
john

You have characters which are encoding using IS0-8859-6 (Arabic)
Jul 19 '05 #7
"wael" <tw*****@hotmai l.com> wrote in message
news:f7******** *************** **@posting.goog le.com...
sorry ,
//bytes order
this was by mistake
//i am sorry if i can not let you understand may be for my bad language i try encode wchar according 'The Unicode Standard and ISO/IEC 10646' this is the format which i need
please look at:
Figure 1-1. Wide ASCII
http://www.unicode.org/book/uc20ch1.html
the picture display how chars look like in binary format
You will find 'A' is = '0000 0000 0100 0001' = (in hex) '0 0 4 1' Other char down (arabic char) = '0000 0110 0011 0011' = in hex '0 6 3 3' the problem is if i try get the binary string of this arabic char it is '0000 0000 1101 0011' which != '0000 0110 0011 0011' for that i must convert '0000 0000 1101 0011' to ISO/IEC

10646'

<snip>

You might want to check out
http://www.dinkumware.com/libDCorX.html CoreX library
character set converters, google on Plauger and/or Pete
Becker IIRC for more info in this newsgroup (apologies if
I'm misunderstandin g what you're trying to do).

- -
Best Regards, John E.
Jul 19 '05 #8
"John Ericson" <je******@pacbe ll.net> wrote in message news:<W8******* **********@news svr25.news.prod igy.com>...
"wael" <tw*****@hotmai l.com> wrote in message
news:f7******** *************** **@posting.goog le.com...
sorry ,
//bytes order
this was by mistake
//i am sorry if i can not let you understand may be for my

bad language
i try encode wchar according 'The Unicode Standard and

ISO/IEC 10646'
this is the format which i need
please look at:
Figure 1-1. Wide ASCII
http://www.unicode.org/book/uc20ch1.html
the picture display how chars look like in binary format
You will find 'A' is = '0000 0000 0100 0001' = (in hex) '0

0 4 1'
Other char down (arabic char) = '0000 0110 0011 0011' =

in hex '0 6 3 3'
the problem is if i try get the binary string of this

arabic char
it is '0000 0000 1101 0011' which != '0000 0110 0011

0011'
for that i must convert '0000 0000 1101 0011' to ISO/IEC

10646'

<snip>

You might want to check out
http://www.dinkumware.com/libDCorX.html CoreX library
character set converters, google on Plauger and/or Pete
Becker IIRC for more info in this newsgroup (apologies if
I'm misunderstandin g what you're trying to do).

- -
Best Regards, John E.

thank you John E.
for try help
http://www.dinkumware.com/libDCorX.html CoreX library
is this library is free >???? and for VC++ 6 ??

thankx
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3650
by: Francis Girard | last post by:
Hi, For the first time in my programmer life, I have to take care of character encoding. I have a question about the BOM marks. If I understand well, into the UTF-8 unicode binary representation, some systems add at the beginning of the file a BOM mark (Windows?), some don't. (Linux?). Therefore, the exact same text encoded in the same UTF-8 will result in two different binary files, and of a slightly different length. Right ?
4
3166
by: Basil | last post by:
Hello. I have compiler BC Builder 6.0. I have an example: #include <strstrea.h> int main () { wchar_t ff = {' s','d ', 'f', 'g', 't'};
1
1772
by: Scott Duckworth | last post by:
Can anyone provide a quick code snippit to open a text file and tell if it's ASCII or Unicode? Thanks
13
3301
by: Tomás | last post by:
Let's start off with: class Nation { public: virtual const char* GetName() const = 0; } class Norway : public Nation { public: virtual const char* GetName() const
40
3227
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages, including asian languages (chinese, japanese, korean, etc). First of all, strings will be passed to my class methods, some of which based on the language (and on the encoding) might contain characters that require more that a single byte.
12
3034
by: damjan | last post by:
This may look like a silly question to someone, but the more I try to understand Unicode the more lost I feel. To say that I am not a beginner C++ programmer, only had no need to delve into character encoding intricacies before. In c/c++, the unicode characters are introduced by the means of wchar_t type. Based on the presence of _UNICODE definition C functions are macro'd to either the normal version or the one prefixed with w. Because...
6
13888
by: archana | last post by:
Hi all, can someone tell me difference between unicode and utf 8 or utf 18 and which one is supporting more character set. whic i should use to support character ucs-2. I want to use ucs-2 character in streamreader and streamwriter. How unicode and utf chacters are stored.
0
1645
by: Anthony Baxter | last post by:
SECURITY ADVISORY Buffer overrun in repr() for UCS-4 encoded unicode strings http://www.python.org/news/security/PSF-2006-001/ Advisory ID: PSF-2006-001 Issue Date: October 12, 2006 Product: Python Versions: 2.2, 2.3, 2.4 prior to 2.4.4, wide unicode (UCS-4) builds only CVE Names: CAN-2006-4980
5
6911
by: Xah Lee | last post by:
If i have a nested list, where the atoms are unicode strings, e.g. # -*- coding: utf-8 -*- ttt=, ,...] print ttt how can i print it without getting the u'\u1234' notation? i.e. i want it print just like this: , ...] I can of course write a loop then for each string use
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.