Re: Unicode

From: JKop (NULL_at_NULL.NULL)
Date: 04/22/04


Date: Thu, 22 Apr 2004 12:01:30 GMT

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



Relevant Pages