473,748 Members | 9,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The nature of string and char[] in .NET

Hello,

I'm trying to write a converter for converting between Big5 and UTF-8,
but I want to make sure a few facts before writing.

1) I know that by default .NET store string in unicode. Would there be
any problem if I store Big5 characters in the string? Or could I set the
codepage setting for individual string?

2) There are basically three types of Unicode scheme - UTF-7, UTF-8 and
UCS-2. Which one does the default Unicode setting refer to?

3) Same as 1) but this time is for char[].

I'm writing this because the webpage I'm writing is in Unicode, it
stores data to MySQL database which store data in Big5, and we also have a
backend written in VB6 which would be nearly rewritting if need to change to
Unicode. Here, I plan to translate the data immediately when read from the
database and vice versa so no other existing part need to be changed. I'm
using LibEx with MyODBC for accessing MySQL.

This post will be crossposted to
microsoft.publi c.dotnet.intern ationalization. (The i18n group seems more
appropiate, but as I'm also asking how strings are stored in .NET
applications, I think it's also good to post in here.)

Any advice would be greatly appreciated. Whether for the questions or
for a better way to fatch the data so no manual translation is needed. :)

Thanks in advance.

Regards,
Lau Lei Cheong
Nov 18 '05 #1
3 1139
Hi,

1) you can set application encoding in web.config :

<globalizatio n
requestEncoding ="utf-8"
responseEncodin g="utf-8"
/>

2) you can convert from one encoding to others by using
Encoding.Conver t Method :
http://msdn.microsoft.com/library/de.../en-us/cpref/h
tml/frlrfSystemText EncodingClassCo nvertTopic1.asp

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
"Natty Gur" <na***@dao2com. com> ???
news:eY******** ******@TK2MSFTN GP10.phx.gbl ???...
Hi,

1) you can set application encoding in web.config :

<globalizatio n
requestEncoding ="utf-8"
responseEncodin g="utf-8"
/> Thanks for the information. :)
2) you can convert from one encoding to others by using
Encoding.Conver t Method :
http://msdn.microsoft.com/library/de.../en-us/cpref/h
tml/frlrfSystemText EncodingClassCo nvertTopic1.asp

It's pity that my attempt to follow this has failed. The modified function
only return question marks to the database.
Seems more modifications is needed for converting multibyte characters.

I've worked so far success to convert unicode string to byte array(big5 code
equivalent). Now I need to convert it back to string. Any idea on that?
Thanks a lot.
Nov 18 '05 #3
Hi,

send me mail. i've back at work sample code that dose it for hebrew
visual to unicode.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

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

Similar topics

6
10778
by: Gaurav | last post by:
Hello, I am using visual c++ 6 and i am having problems with string to work. ******** Here is the program project.cpp********* #include <iostream.h> #include <string> #include "stdafx.h"
2
4781
by: Andrew | last post by:
I have written two classes : a String Class based on the book " C++ in 21 days " and a GenericIpClass listed below : file GenericStringClass.h // Generic String class
7
10628
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using namespace std; : : vector<string>* getTyphoon()
13
11025
by: M | last post by:
Hi, I've searched through the previous posts and there seems to be a few examples of search and replacing all occurrances of a string with another string. I would have thought that the code below would work... string gsub(const string & sData, const string & sFrom,
16
16425
by: Khuong Dinh Pham | last post by:
I have the contents of an image of type std::string. How can I make a CxImage object with this type. The parameters to CxImage is: CxImage(byte* data, DWORD size) Thx in advance
16
17463
by: Don Starr | last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string (including nul), or the size of a pointer? For example, assuming a char is 1 byte and a char * is 4 bytes, should the following yield 4, 5, of something else? (And, if something else, what determines the result?) char x = "abcd"; printf( "%d\n", sizeof( x ) ); -Don
7
4361
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have type of "const char *". Right? But why does the compiler I am using allow s to be modified, instead of generating compile error?
3
5091
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages (Java). It stores character strings, and resizes itself to accommodate new strings when needed. Interface: ----------
8
4273
by: Lawrence D'Oliveiro | last post by:
If triple-quoted strings had the Python-nature, then they would take indentation into account. Thus: """this is a multi-line string.""" would be equivalent to
0
8991
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
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9325
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
9249
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
8244
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
6076
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
4607
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
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
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

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.