473,885 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert System::String to CString??

Hi

How do I convert a managed System::String to a CString. I need to handle
unicode characters ( Japan and Chinese ) as well as "normal" ANSI
characters.

I have tried the following

char* p =
(char*)System:: Runtime::Intero pServices::Mars hal::StringToHG lobalAnsi(
msg ).ToPointer();
CString str(p);

which works fine as long we are not dealing with Japanese. How do I handle
both situations??

Regards Morten

Nov 16 '05 #1
3 25568
Hi Morten,

Thanks posting in the group!

You can refer to the following KB article, maybe you can find good
resolution from it:
HOW TO: Convert from System::String* to Char* in Visual C++ .NET
http://support.microsoft.com/?id=311259

Hope that helps!
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Nov 16 '05 #2
Thanks :-)

Regards Morten
"Gary Chang [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:gK******** ******@cpmsftng xa06.phx.gbl...
Hi Morten,

Thanks posting in the group!

You can refer to the following KB article, maybe you can find good
resolution from it:
HOW TO: Convert from System::String* to Char* in Visual C++ .NET
http://support.microsoft.com/?id=311259

Hope that helps!
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 16 '05 #3
Hi Morten,
How do I convert a managed System::String to a CString. I need to handle
unicode characters ( Japan and Chinese ) as well as "normal" ANSI
characters.

I have tried the following

char* p =
(char*)System:: Runtime::Intero pServices::Mars hal::StringToHG lobalAnsi(
msg ).ToPointer();
CString str(p);

which works fine as long we are not dealing with Japanese. How do I handle
both situations??


You'd probably need to stay in unicode (compiling your code for unicode,
instead of ANSI). Ohh, BTW, there's a CString constructor that already takes
a System::String* as an argument :)

--
Tomas Restrepo
to****@mvps.org
Nov 16 '05 #4

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

Similar topics

1
2669
by: Peter Schmitz | last post by:
Hi, is there any way to convert a managed System::String var to a BYTE pointer (BYTE*)? Thanks a lot Peter
3
6041
by: Tim Mulholland | last post by:
How can i (using Managed C++) convert a System::String object containing basic text into a char* object? Thanks in advance, Tim
15
10847
by: Yifan | last post by:
Hi Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks Yifan
1
3846
by: SteveK | last post by:
Trying to wrap an unmanaged class. Here is the function I'm trying to wrap: bool Init(PCSTR filename, PCSTR username, PCSTR password, PCSTR working); In my managed C++ class, I have a method like this: bool CSUSSWrapper::Init(String* filename, String* username, String* password, String* working) {
11
11886
by: Code[R] | last post by:
hello all, i've a problem :s i've tried to convert a "system::string" (a textbox) to an "int" but i have only found a function to convert system::string to char and char to int :s : Convert::ToInt32(PtrToStringChars(ligne23->Text)); but i get a bug :s can you help me ? (sorry for my english i'm french)
0
1253
by: Tommaso Caldarola | last post by:
I have a custom collection of custom objects. I bind a DataGrid with collection1, a property of custom object is a ReferenceType (another custom object). For that property in the datagrid I see a combobx, when the user selects an item I get the following error: Unable to update data. Unable to convert System.String to CustomObject type.
2
2070
by: sovarschizsuzsa | last post by:
Hy! I have written a MC++ wrapper DLL file for use in a C# project. This wrapper DLL is built on a C DLL. I have the following functions in the C DLL: int First(char* a1, char* a2, void* *a3, bool a4); void Second(void* lic); I've converted this in MC++ dll in the following way: int First(System::String* a1, System::String* a2, System::Object* a3,
14
10655
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have seen the following function to convert from a System::String^ to a const wchar_t*. I would like to get a LPCTSTR and AFAIK LPCTSTR is equal to const wchar_t*. Then it should all work right? But I only get the first character. And when I try to do std::wstring l_s(convert(somestring)) I get really strange characters into l_s string representation, but when I check l_s individual characters they look ok. const wchar_t* convert(...
1
2790
by: AJ32 | last post by:
Hi, I am writting a program in visual c++ expres that takes user input and sends it to files, I am using a text box to get the input. The problem is, that I cannot use a "system string" when writting to the file: string ^textboxinput = textBox1->Text; ofstream File; File.open("newfile", ios::app | ios::out); File << "contents" << textboxinput << endl; File.close(); An error occurs and says I can't use a system string when writting to...
0
9956
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
11172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10429
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
9592
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...
1
7987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7139
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
5808
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...
1
4627
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
3
3245
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.