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

unicode std::string

Hi,

Is there a unicode equivalent to std::string?
Jul 23 '05 #1
9 22516
vsgdp wrote:
Hi,

Is there a unicode equivalent to std::string?


std::wstring?
Jul 23 '05 #2
red floyd wrote:
vsgdp wrote:
Is there a unicode equivalent to std::string?


std::wstring?


for UTF-16, not for UTF-8.

Jul 23 '05 #3
Panjandrum wrote:
red floyd wrote:
vsgdp wrote:
Is there a unicode equivalent to std::string?


std::wstring?

for UTF-16, not for UTF-8.

hence the question mark.
Jul 23 '05 #4
Panjandrum wrote:
red floyd wrote:
vsgdp wrote:
> Is there a unicode equivalent to std::string?


std::wstring?


for UTF-16, not for UTF-8.


So you say unicode is only UTF-8? And std::string is always UTF-16?

Jul 23 '05 #5
Rolf Magnus wrote:
Panjandrum wrote:
red floyd wrote:
vsgdp wrote:
> Is there a unicode equivalent to std::string?

std::wstring?


for UTF-16, not for UTF-8.


So you say unicode is only UTF-8? And std::string is always UTF-16?


std::wstring and std::string are both not appropriate for
variable-length character encodings like UTF-8.

Jul 23 '05 #6
Panjandrum wrote:
Rolf Magnus wrote:
Panjandrum wrote:
> red floyd wrote:
>> vsgdp wrote:
>> > Is there a unicode equivalent to std::string?
>>
>> std::wstring?
>
> for UTF-16, not for UTF-8.


So you say unicode is only UTF-8? And std::string is always UTF-16?


std::wstring and std::string are both not appropriate for
variable-length character encodings like UTF-8.


Yes, but there are unicode encodings that don't need variable-length
characters.

Jul 23 '05 #7
Panjandrum wrote:
Rolf Magnus wrote:
Panjandrum wrote:
red floyd wrote:
vsgdp wrote:
> Is there a unicode equivalent to std::string?

std::wstring?

for UTF-16, not for UTF-8.

std::wstring does not specify any encoding type or any character set.

The most common implementations of std::wstring use Unicode
character set, and either UCS-4, UCS-2 or UTF-16 encoding.
But this is not a requirement.
std::wstring and std::string are both not appropriate for
variable-length character encodings like UTF-8.


std::string is appropriate for UTF-8.

But you must remember that functions like size() and find() will
apply to the encoded bytes, not to the decoded version.

If that was your issue, then you could also say that std::wstring
is not appropriate for any Unicode encoding, because of combining
characters (ie. the string length won't match the number of
display characters).

Of course the correct answer is that you should engage your
brain when manipulating Unicode strings, and be aware of
these issues. Many applications do indeed use std::string for
UTF-8 processing.

Jul 23 '05 #8
Old Wolf wrote:
Panjandrum wrote:
std::wstring and std::string are both not appropriate for
variable-length character encodings like UTF-8.
std::string is appropriate for UTF-8.

But you must remember that functions like size() and find() will
apply to the encoded bytes, not to the decoded version.


You mean std::string is appropriate, "just" most member functions don't
work?
If that was your issue, then you could also say that std::wstring
is not appropriate for any Unicode encoding, because of combining
characters (ie. the string length won't match the number of
display characters).
You use normalized UTF-16.
Of course the correct answer is that you should engage your
brain when manipulating Unicode strings, and be aware of
these issues. Many applications do indeed use std::string for
UTF-8 processing.


Disburden the brain by using sufficient tools for the task.

Jul 23 '05 #9


Panjandrum schreef:
Old Wolf wrote:
Panjandrum wrote:
std::wstring and std::string are both not appropriate for
variable-length character encodings like UTF-8.


std::string is appropriate for UTF-8.

But you must remember that functions like size() and find() will
apply to the encoded bytes, not to the decoded version.


You mean std::string is appropriate, "just" most member functions don't
work?


"don't work" is nonsense. They work, but the results are not what you
would like.
If that was your issue, then you could also say that std::wstring
is not appropriate for any Unicode encoding, because of combining
characters (ie. the string length won't match the number of
display characters).


You use normalized UTF-16.


Since Unicode 4, Unicode characters can no longer be encoded in 16
bits. Even with normalization you need 20 bits, or pairs of 16 bits.
However, there are implementations in which wchar_t is 32 bits.
(Note: wchar_t doesn't haave to be Unicode)

Regards,
Michiel Salters

Jul 23 '05 #10

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

Similar topics

6
by: nico | last post by:
In my python scripts, I use a lot of accented characters as I work in french. In order to do this, I put the line # -*- coding: UTF-8 -*- at the beginning of the script file. Then, when I need...
3
by: Shrii | last post by:
1.I read a unicode file by using codec 2.I want to pass that string to exec() statement 3.But one of my character (U+0950) in that string is not showing properly in the output got by that exec()...
2
by: aurora | last post by:
I have some unicode string with some characters encode using python notation like '\n' for LF. I need to convert that to the actual LF character. There is a 'unicode_escape' codec that seems to...
5
by: wanghz | last post by:
Hello, everyone. I have a problem when I'm processing unicode strings. Is it possible to get the 8bit-string representation of any unicode string? Suppose I get a unicode string: a =...
7
by: pattreeya | last post by:
Hello, how can I get the number of byte of the string in python? with "len(string)", it doesn't work to get the size of the string in bytes if I have the unicode string but just the length. (it...
8
by: Preben Randhol | last post by:
Hi If I use len() on a string containing unicode letters I get the number of bytes the string uses. This means that len() can report size 6 when the unicode string only contains 3 characters...
1
by: willie | last post by:
>willie wrote: wrote:
0
by: mimi | last post by:
#include <fstream> #include "stdio.h" int main() { // std::wofstream strm2("test.txt"); // strm2 << L"ÎÒ°®±±¾©Ìì°²ÃÅ"; FILE *hFile = fopen("test.txt", "wb+"); wchar_t *buffer =...
0
by: Jean-Paul Calderone | last post by:
On Mon, 5 May 2008 16:05:08 +0200, Simon Posnjak <sposnjak@gmail.comwrote: You need to provide some more information about `some_module.some_thing´. How is it implemented? What Python type does...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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,...
0
jinu1996
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...
0
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...
0
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,...

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.