473,388 Members | 1,399 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,388 software developers and data experts.

How can I convert UNICODEwchar to ANSIC_char using STL.

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

=============out===========
hello
====end out========

I know in Windows,I can use WideCharToMultiByte 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********@hotmail.com
¹«Ë¾£º http://www.lingtu.com/
ÁéͼÔÚÏß:http://www.51ditu.com/
--------------------------
Aug 10 '06 #1
1 3338

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

=============out===========
hello
====end out========

I know in Windows,I can use WideCharToMultiByte 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
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...
2
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...
10
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
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...
2
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...
6
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...
4
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...
2
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...
6
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.