An example of string is the italian word "più". Here I can visually count 3 chars: p, i and ù. But if I use "più".size() the result is 4
std::string ppp = "più"; size_t sss = ppp.size(); here sss is 4. L. On Mar 21, 2013, at 9:48 AM, Luther Baker <lutherba...@gmail.com> wrote: > I don't think your example makes sense. How is 'num of char of "test"' ever 3? > > In a particular string representation, all letters are each, generally > represented with the same number of bytes. > > On Mar 21, 2013, at 3:27 AM, Luca Ciciriello <luca_cicirie...@hotmail.com> > wrote: > >> Hi all. >> I'm using in my iOS project some Objective-C++ modules. Here I have some >> conversion from NSString to C++11 std::string. After this conversion I found >> (correctly) in my std::string some 2-byte characters. >> My question is: How can I count the number of chars and not the numbers of >> byte in my std::string? >> >> Example. >> >> if my std::string test contains 2 1-byte chars and 1 2-byte (UNICODE) char, >> I have: >> >> num of char of "test" = 3 >> num of byte (test.size()) of "test" = 4 >> >> Luca. >> >> >> >> >> >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/cocoa-dev/lutherbaker%40gmail.com >> >> This email sent to lutherba...@gmail.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com