473,769 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I convert UNICODEwchar to ANSIC_char using STL.

#include <xxx>
int main()
{
const wchar* pwcHello=L"hell o";
char* pcHello;
xxxxxx //do something using stl
cout<<pcHello<< endl;
}

=============ou t===========
hello
====end out========

I know in Windows,I can use WideCharToMulti Byte to convert wchar_t Encoding
in Unicode to char Encoding in ANSI .

How can I do this using STL?

--
= = = = = = = = = = = = = = = = = = = = = =

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ¡ÖÂ
Àñ£¡

ÕÅÖ¾¸Õ
----------------------------
Co.: ±±¾©ÁéͼÐÇѶ¿Æ¼ ¼ÓÐÏÞ¹«Ë¾ Ñз¢²¿
Ad.: ±±¾©Êк£µíÇøÖй Ø´åÈí¼þÔ°ººÍõ´ó Ïöþ²ãDÇø
ZIP£º 100094
Tel.: 010-82825800£*8006
Mobile:
Mail£ºzh******* ***@lingtu.com
MSN: re********@hotm ail.com
¹«Ë¾£º http://www.lingtu.com/
ÁéͼÔÚÏß:http://www.51ditu.com/
--------------------------
Aug 10 '06 #1
1 3363

recover wrote:
#include <xxx>
int main()
{
const wchar* pwcHello=L"hell o";
char* pcHello;
xxxxxx //do something using stl
cout<<pcHello<< endl;
}

=============ou t===========
hello
====end out========

I know in Windows,I can use WideCharToMulti Byte to convert wchar_t Encoding
in Unicode to char Encoding in ANSI .

How can I do this using STL?
The facetious answer is to just take every other byte skipping the
first.

In order to do this with other strings though you need to understand
the character encodings in use.

You cannot convert an arbitrary string from Unicode to ASCII because
there are many more Unicode characters than there is room for in ASCII.
You can't always convert it to Shift_JIS and you can't always convert
it to TIS-620.

The simplest thing to do is to store tables of Unicode against other
encoding and go through that or to use a library like ICU
(International Components for Unicode) to do the conversions for you.

There aren't simple answers in any of this. The route that involves the
least learning is to just keep everything as Unicode strings - then you
only need to understand the different Unicode encodings. If you want to
convert to other narrow string formats then you need to learn about all
of these individually - or atleast learn a lot about the libraries that
help handle them.
K

Aug 10 '06 #2

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

Similar topics

0
2370
by: Zak Chababe | last post by:
Hi, We are in the process of converting thousands of MS word documents into some sort of database files like sql or comma separated files. Is there something out there with Perl that allows me to convert all these word documents? Any help is appreciated. /Zak
2
4498
by: news | last post by:
We just upgraded our phpMyAdmin GUI to the latest stable version, and now the SQL queries are doing odd additions. First, without changing the database it's connecting to at all, there's a new column "collation" for all the tables, and the value in all of them is: "latin1_swedish_ci". I'm doubting that's what it should be. And any SQL querey formulates like:
10
162680
by: bonnie.tangyn | last post by:
Dear all In my ASP page, user can enter date in dd/mm/yyyy format. How can I use Javascript to convert dd/mm/yyyy to yyyy-mm-dd hh:mm:ss. Please give me some advices. Cheers Bon
2
4772
by: suji | last post by:
Hai, Are there any 3rd party controls who provide free libraries to convert my html form to pdf in c#? I need to have a button on my form, that should convert my page to pdf format. Can any one help me to write code for that in c# with libraries? regards, Suji.
2
8917
by: Ch Pravin | last post by:
Hi All: I am having the following xml which i need to convert to excel using xslt. Please help me out. Afghanistan.xml <?xml version="1.0" encoding="utf-16"?> <Languages BuildVersion="1,5,0815,0 " CountryName="Afghanistan" > <Language locale="English">
6
3401
by: Muthu08 | last post by:
Hello Experts, I'm trying to convert an dynamic XML doc into HTML using XSLT. In the example I have shown one form(form1)...But there could be multiple forms....names are unknown and each one could have o or more childforms .I want to display form1 as <th> element followed by attributes,then display Childform1 as header(if there is a child form) .See the XSl below. Is there a way to check if form1 has childforms...so i could render...
4
4529
by: thomasc1020 | last post by:
This is regarding VB.NET 2003. Variable 'Date' is a string and it contains date information in this format: "DEC/05/2007". Now I am trying to convert the format as "2007-12-05". Is it possible to convert the arrangement using 'Format' method? If so, please educate me how I can do such operation. Thank you!
2
4500
by: David | last post by:
Hey can anyone help me convert a javascript array into a ruby array. Ive been struggling with this since friday to no avail. This is the function with the ajax.request call that is supposed to convert the array using JSON, but I keep getting a 422(Unprocessable Entity) error. Im not sure what is wrong. function test() { for(i=1;i<22;i++){ if (document.getElementById(i+'d').className ==
6
1860
by: BOMEz | last post by:
So i've recently been starting to program PHP in an object oriented way, but I'm running into some difficulties in from a design stand point and from an object oriented stand point: Issue 1: In my class I cannot give visibility to any variable, it simple breaks everything. For example if I do: private $private = 'Private'; I get the error : The error is the same if I use public or protected. I have tried declaring a a private variable in...
0
9590
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
9424
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,...
0
10223
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...
1
10000
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
8879
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
7413
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
6675
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
5310
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...
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.