473,785 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UCS and BMP Character Sets

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 thousand
characters. Reference http://en.wikipedia.org/wiki/Univers..._Character_Set

How do I specify a character set of UCS (ISO/IEC 10646) when invoking
a string constructor?

Thanks,
Jeff
Jeffrey Walton
Nov 20 '07 #1
3 1753
Jeffrey Walton <no******@gmail .comwrote:
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 thousand
characters.
<snip>
How do I specify a character set of UCS (ISO/IEC 10646) when invoking
a string constructor?
You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).

You want to use System.Text.Enc oding.GetString (byte[]) to convert from
bytes to a string.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Nov 20 '07 #2
Hi John,

Thanks for the quick reply.
You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).
I know I am off slightly with respect to the paradigm.
You want to use System.Text.Enc oding.GetString (byte[]) to convert from
bytes to a string.
Thank you very much. I was cruising your site earlier. The example
presented is based on a Stream (but I have a byte array). I was hoping
for a more applicable answer.

I also saw a T.61 string is availble as a CodePage (http://
msdn2.microsoft .com/en-us/library/system.text.enc odinginfo.aspx) . How
does on set it in C# (or is there an overload in
System.Text.Enc oding.GetString () which uses it?).
Thanks Again,
Jeff

On Nov 20, 2:21 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
Jeffrey Walton <noloa...@gmail .comwrote:
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 thousand
characters.

<snip>
How do I specify a character set of UCS (ISO/IEC 10646) when invoking
a string constructor?

You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).

You want to use System.Text.Enc oding.GetString (byte[]) to convert from
bytes to a string.

--
Jon Skeet - <sk...@pobox.co m>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
World class .NET training in the UK:http://iterativetraining.co.uk
Nov 20 '07 #3
Jeffrey Walton <no******@gmail .comwrote:
You don't build a string from bytes, you build it from Unicode
characters (or UTF-16 code points really).
I know I am off slightly with respect to the paradigm.
You want to use System.Text.Enc oding.GetString (byte[]) to convert from
bytes to a string.
Thank you very much. I was cruising your site earlier. The example
presented is based on a Stream (but I have a byte array). I was hoping
for a more applicable answer.
Okay, to load a string from a Stream, you use a StreamReader with a
suitable Encoding.
I also saw a T.61 string is availble as a CodePage (http://
msdn2.microsoft .com/en-us/library/system.text.enc odinginfo.aspx) . How
does on set it in C# (or is there an overload in
System.Text.Enc oding.GetString () which uses it?).
You can supply a code page to Encoding.GetEnc oding.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Nov 20 '07 #4

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

Similar topics

3
2024
by: Thom McGrath | last post by:
I have a text area that people should type in (duh) which will later be displayed for other users via HTML. I've taken care of the HTML aspect in a pretty cool way, but I worry about character sets now. Everything works for me, but I use UTF-8. When the form is submitted, how do I know what character set the data is coming in? I need to know this to perform htmlentities on the data and have it work properly. All my pages are defined as...
7
2929
by: WindAndWaves | last post by:
Hi Folk Here I am writing my first php / mysql site, almost ready, and now this... charactersets.... The encoding that I use on my webpage is: <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"> When people enter new data I use
4
1404
by: siliconmike | last post by:
All I know is that there are 8 bit numbers from 0 to 255 mapped to characters like A, B, C, D and some strange looking ones (like the ones used to make boxes in old PC text modes) all these being called ASCII characters. So, what in a nutshell does "character sets" mean and how are they helpful in displaying multiple languages ? Any simple explanation? Mike
37
10173
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be accidentally entered are properly represented when the document is served. My programming language allows me to get the ascii value for any individual character so what I am doing when a change is saved is to look at each character in the content and...
9
2927
by: jraul | last post by:
1) Am I correct that C++ does not have a defined character set? In particular, a platform might not use the ASCII character set? 2) C++ supports wchar_t types. But again, this has no defined character set? For instance, it might not be a unicode character set?
0
10155
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
10095
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
9953
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
8978
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
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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.