I want to write a C++ prog in Unicode.
int main(void)
{
cout << L"Hello!";
}
Anyone got any suggestions?!
Thanks 13 2323
"JKop" <NU**@NULL.NULL> wrote in message
news:vc******************@news.indigo.ie... I want to write a C++ prog in Unicode.
int main(void) {
cout << L"Hello!";
}
Anyone got any suggestions?!
Thanks
You might have more luck if you use wcout instead of cout, but C++ has no
specific support for Unicode.
john
John Harrison posted: "JKop" <NU**@NULL.NULL> wrote in message news:vc******************@news.indigo.ie... I want to write a C++ prog in Unicode.
int main(void) {
cout << L"Hello!";
}
Anyone got any suggestions?!
Thanks You might have more luck if you use wcout instead of cout, but C++
has no specific support for Unicode.
john
Thanks,
Where can I get "wcout"?
"JKop" <NU**@NULL.NULL> wrote in message
news:Ix******************@news.indigo.ie... John Harrison posted:
"JKop" <NU**@NULL.NULL> wrote in message news:vc******************@news.indigo.ie... I want to write a C++ prog in Unicode.
int main(void) {
cout << L"Hello!";
}
Anyone got any suggestions?!
Thanks
You might have more luck if you use wcout instead of cout, but C++
has no specific support for Unicode.
john
Thanks,
Where can I get "wcout"?
From the iostream header file.
#include <iostream>
int main()
{
std::wcout << L"hello world\n";
}
john
I'm getting 434a4.
what it does?
John Harrison wrote: "JKop" <NU**@NULL.NULL> wrote in message news:vc******************@news.indigo.ie... I want to write a C++ prog in Unicode.
int main(void) {
cout << L"Hello!";
}
Anyone got any suggestions?!
Thanks
You might have more luck if you use wcout instead of cout, but C++ has no specific support for Unicode.
john
"myName" <my******@myweb.com> wrote in message
news:40***************@myweb.com... I'm getting 434a4. what it does?
That's probably the address of the string. Compiler support for Unicode or
even for wide characters often isn't very good. For more help I'd recommend
asking on a newsgroup that supports your particular compiler. They'll be
able to tell you what compiler specific stuff you have to do.
John
On Thu, 22 Apr 2004, JKop wrote: I want to write a C++ prog in Unicode.
You could also overload operator<< for wide character strings.
#include <iostream>
#include <cwchar>
/* stream inserter for wide character strings */
std::ostream&
operator<<(std::ostream& os, const wchar_t* wcs)
{
size_t len = std::wcslen(wcs) + 1;
len *= 2; //assumption: length(mbs) <= 2 * length(wcs)
char* mbs = new char[len];
std::wcstombs(mbs, wcs, len);
os << mbs;
delete [] mbs;
return os;
}
This method has worked fine for me. But if you can use std::wcout, then
prefer it to the code given above. (Even if one has to use std::cout,
this code could be improved since we traverse the wide string twice.
Any suggestions?)
--
Claudio Jolowicz http://www.doc.ic.ac.uk/~cj603
Claudio Jolowicz posted: On Thu, 22 Apr 2004, JKop wrote:
I want to write a C++ prog in Unicode.
You could also overload operator<< for wide character strings.
#include <iostream> #include <cwchar>
/* stream inserter for wide character strings */ std::ostream& operator<<(std::ostream& os, const wchar_t* wcs) { size_t len = std::wcslen(wcs) + 1; len *= 2; //assumption: length(mbs) <= 2 * length(wcs) char* mbs = new char[len]; std::wcstombs(mbs, wcs, len); os << mbs; delete [] mbs; return os; }
This method has worked fine for me. But if you can use std::wcout,
then prefer it to the code given above. (Even if one has to use
std::cout, this code could be improved since we traverse the wide string
twice. Any suggestions?)
The thing is that I need Unicode!! I want to display Arabic currency!
-JKop
>You could also overload operator<< for wide character strings.
[snip my code multiplying string length by 2]
Better use MB_LEN_MAX to compute maximum length of string.
#include <iostream>
#include <cwchar>
/* stream inserter for wide character strings */
std::ostream&
operator<<(std::ostream& os, const wchar_t* wcs)
{
size_t len = std::wcslen(wcs) + 1;
len *= MB_LEN_MAX;
char* mbs = new char[len];
std::wcstombs(mbs, wcs, len);
os << mbs;
delete [] mbs;
return os;
}
int main()
{
std::cout << L"Hello." << std::endl;
return 0;
}
--
Claudio Jolowicz http://www.doc.ic.ac.uk/~cj603
> The thing is that I need Unicode!! I want to display Arabic currency!
-JKop
C++ has no built in support for Unicode. Are you prepared to buy a third
party library that gives you that support? Are you working on a operating
system that supports Unicode?
Unless the answers to both those questions are yes, then I don't think you
are going to get very far. As I said before the best place to ask about this
is not a C++ group, because C++ has no support for Unicode.
So try again on a group that supports whatever combination of operating
system and compiler you are using. Have a look here for suggestions http://www.slack.net/~shiva/welcome.txt
john
"JKop" <NU**@NULL.NULL> wrote in message
news:uu******************@news.indigo.ie... The thing is that I need Unicode!! I want to display Arabic currency!
In that case, you'd better be sure you're using the right
codecvt facet when you perform wide I/O. See our CoreX
library for the tools that are missing from Standard C++.
P.J. Plauger
Dinkumware, Ltd. http://www.dinkumware.com
"John Harrison" <jo*************@hotmail.com> wrote in message news:<c6************@ID-196037.news.uni-berlin.de>... "JKop" <NU**@NULL.NULL> wrote in message news:Ix******************@news.indigo.ie... John Harrison posted:
"JKop" <NU**@NULL.NULL> wrote in message news:vc******************@news.indigo.ie... > > I want to write a C++ prog in Unicode. > > > int main(void) > { > > cout << L"Hello!"; > > } > > > Anyone got any suggestions?! > > Thanks
You might have more luck if you use wcout instead of cout, but C++ has no specific support for Unicode.
john
Thanks,
Where can I get "wcout"?
From the iostream header file.
#include <iostream>
int main() { std::wcout << L"hello world\n"; }
john
Just a general heads-up here ... I think you also have to have some
sort of local OS-level support for Unicode for that to work. For
example, I use g++ on cygwin, and my compiler does not recognize wcout
as a member of the std namespace. I looked at the <iostream> header,
and it has an #ifdef block around the std::wcout declaration that
"hides" it when there is no wchar support on my system, which is
apparently true in my case.
HTH, Dave Moore
Dave Moore wrote: Just a general heads-up here ... I think you also have to have some sort of local OS-level support for Unicode for that to work. For example, I use g++ on cygwin, and my compiler does not recognize wcout as a member of the std namespace. I looked at the <iostream> header, and it has an #ifdef block around the std::wcout declaration that "hides" it when there is no wchar support on my system, which is apparently true in my case.
Well, somebody's confused. wchar_t is part of the C and C++ languages.
The encoding used for wchar_t doesn't have to be Unicode. std::wcout is
part of the standard C++ library. The C and C++ standards don't make
these things dependent on the OS, so if your compiler doesn't provide
them it doesn't conform to those standards.
--
Pete Becker
Dinkumware, Ltd. ( http://www.dinkumware.com)
"JKop" <NU**@NULL.NULL> wrote in message
news:vc******************@news.indigo.ie... I want to write a C++ prog in Unicode.
int main(void) {
cout << L"Hello!";
}
Anyone got any suggestions?!
Thanks
if you mean making your code translatable to different programming
languages, you could just substitute cout with output
function main
output "Hello!"
something like that This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael Weir |
last post by:
I'm sure this is a very simple thing to do, once you know how to do it, but
I am having no fun at all trying to write utf-8 strings to a unicode file.
Does anyone have a couple of lines of code...
|
by: Bill Eldridge |
last post by:
I'm trying to grab a document off the Web and toss it
into a MySQL database, but I keep running into the
various encoding problems with Unicode (that aren't
a problem for me with GB2312, BIG 5,...
|
by: Francis Girard |
last post by:
Hi,
For the first time in my programmer life, I have to take care of character
encoding. I have a question about the BOM marks.
If I understand well, into the UTF-8 unicode binary...
|
by: Zenobia |
last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice
features such as:
* rewrite source code
* check syntax
* global search & replace (through several files at...
|
by: webdev |
last post by:
lo all,
some of the questions i'll ask below have most certainly been discussed
already, i just hope someone's kind enough to answer them again to help
me out..
so i started a python 2.3...
|
by: Neil Schemenauer |
last post by:
python-dev@python.org.]
The PEP has been rewritten based on a suggestion by Guido to change
str() rather than adding a new built-in function. Based on my
testing, I believe the idea is...
|
by: Nikolay Petrov |
last post by:
How can I convert DOS cyrillic text to Unicode
|
by: Jeff |
last post by:
Hi -
I'm setting up a streamreader in a VB.NET app to read a text file and
display its contents in a multiline textbox.
If I set it up with System.Text.Encoding.Unicode, it reads a unicode...
|
by: Tomás |
last post by:
Let's start off with:
class Nation {
public:
virtual const char* GetName() const = 0;
}
class Norway : public Nation {
public:
virtual const char* GetName() const
|
by: ChaosKCW |
last post by:
Hi
I am reading from an oracle database using cx_Oracle. I am writing to a
SQLite database using apsw.
The oracle database is returning utf-8 characters for euopean item
names, ie special...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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: 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...
| |