473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

UCS-2 to ASCII

I'm trying to convert UCS-2 code to ASCII. Does anyone have an example in
C?.
thanks.
Nov 14 '05 #1
4 10176
test wrote:
I'm trying to convert UCS-2 code to ASCII. Does anyone have an example in
C?.


for( i=0; i!=len; ++i)
if( (ucs2[i]>=0) && (ucs2[i]<127))
ascii[i] = ucs2[i];
else
conversion_failed();
ascii[i] = '\0';

Yes, not all UCS-2 can be converted to ASCII.
Yes, character code 127 is not part of ASCII.

Uli

Nov 14 '05 #2
On 2005-02-22 01:05:39 -0500, Ulrich Eckhardt <do******@knuut.de> said:
test wrote:
I'm trying to convert UCS-2 code to ASCII. Does anyone have an example in C?.


for( i=0; i!=len; ++i)
if( (ucs2[i]>=0) && (ucs2[i]<127))
ascii[i] = ucs2[i];
else
conversion_failed();
ascii[i] = '\0';

Yes, not all UCS-2 can be converted to ASCII. Yes, character code 127
is not part of ASCII.


[OT]
According to ISO-646 and ISO-10646, character 127 is the "DEL" control
character, and is indeed part of both ASCII and Unicode.
[/OT]
--
Clark S. Cox, III
cl*******@gmail.com

Nov 14 '05 #3
# Yes, character code 127 is not part of ASCII.

Rubout character.

In the good old days of paper tape, you couldn't remove a mistake. Instead you
backed up and punched all columns. The resulting all ones code (31, 63, 127, or
255) was a signal that character position was supposed to be ignored.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
OOOOOOOOOO! NAVY SEALS!
Nov 14 '05 #4
On Tue, 22 Feb 2005 19:03:26 -0000,
SM Ryan <wy*****@tango-sierra-oscar-foxtrot-tango.fake.org> wrote:

# Yes, character code 127 is not part of ASCII.

Rubout character.

In the good old days of paper tape, you couldn't remove a mistake. Instead you
backed up and punched all columns. The resulting all ones code (31, 63, 127, or
255) was a signal that character position was supposed to be ignored.


That was, by the way, 127 plus even parity on 8 channel paper tape.
Villy
Nov 14 '05 #5

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

Similar topics

1
by: Oleg Leschov | last post by:
Where can I find a list and documentation for codecs? What I want to do is to make a unicode string out of unicode data. for example. I am parsing NTFS metadata, that contains filenames as UCS-2...
8
by: wael | last post by:
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...
2
by: panda | last post by:
Dear ALL, How can I create an database of codepage UTF-16/UCS-2 in AIX DB2 V8? I tried to use "db2set db2codepage=1200" and "db2 terminate" but failed. I also tried to use "db2 create db abc...
1
by: Bill | last post by:
I've having a very strange problem. In a large solution it may occur only on 30-40% of the projects that include Forms/UserControls. I design the form at design-time, justify the controls etc....
9
by: beni.cherniavsky | last post by:
Python seems to be missing a UCS-32 codec, even in wide builds (not that it the build should matter). Is there some deep reason or should I just contribute a patch? If it's just a bug, should I...
0
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...
12
by: Boris | last post by:
I'm trying to find out what the steps look like to upgrade a program (which is used on Windows and Unix) from Windows-1252 (the Windows "ANSI" code page) to UCS-2. Currently the program reads and...
0
by: ajibits | last post by:
hi ppl For my application, I need to encode/decode the information in either of these two following coding schemes. Contents: Alpha tagging(name) of the associated dialling number. ...
3
by: Jeffrey Walton | last post by:
HI All, I' working on an ASN.1 parser. The Content Octets (data values) are stored in a byte. The conversion of byte to char is fairly trivial. BMP is a special case of UCS, using the lower 65...
3
by: sm0a9f4 | last post by:
Hi everyone, I'm a noob with a problem... In non-IE browsers, I'm trying to load a UCS-2 (UTF-16) encoded file using the following lines: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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...
0
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,...

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.