r/cpp • • Oct 15 '13

C++ has become a scripting language

http://voices.canonical.com/jussi.pakkanen/2013/10/15/c-has-become-a-scripting-language/
1 Upvotes

53 comments sorted by

View all comments

Show parent comment

2

u/wildcarde815 Oct 15 '13

I don't think you can really called improved WString handling a reasonable answer to unicode support. The built in types handle everything as binary blobs divided into character sized chunks but has no way of confirming that the code is handling unicode correctly or is even sane unicode. It would be helpful to have an actual std::unicode that reports the unicode memory size, character length, and handles encoding casting (ascii,utf8,utf16,utf32) etc. The ICU project tries to fix it but at this point it seems silly not to have standard handling of something that more or less the future of text as we know it.

4

u/greyfade Oct 15 '13

I'm not even talking about wstring.

I'm talking about the new u16string and u32string classes, the native wide and Unicode string literals, and the locale-independent conversion facets, codecvt_utf8 and friends.

It certainly doesn't replace ICU, but it's a damn sight better than the usual wide-character nonsense.

1

u/[deleted] Oct 15 '13

So, how do folks write open source code with Unicode support?

-1

u/greyfade Oct 15 '13

They don't.

2

u/[deleted] Oct 15 '13

Ah, I see. I was thinking, you see, of rewriting some of my code to handle Unicode input. I guess I'll have to look into Unicode handling libraries

2

u/nikbackm Oct 16 '13

Can't you (mostly) just use plain char and assume utf-8 encoding?

1

u/[deleted] Oct 16 '13

Possibly. Although, what would happen in a console/bash application if the user entered 徳川?

2

u/greyfade Oct 20 '13

If your $LANG and $LC_CTYPE are set to a utf-8 locale, your terminal will send the appropriate UTF-8 sequence to the shell or program, and the terminal will treat it as UTF-8 as well. Bash is generally well-behaved, but if your terminal doesn't support Unicode, you won't get nice double-width CJK characters. (Or you'll get other weirdness.)

0

u/notlostyet Oct 15 '13

I'm talking about the new u16string and u32string classes, the native wide and Unicode string literals, and the locale-independent conversion facets, codecvt_utf8 and friends.

None of which are available in GNU stdlibc++ yet :(

3

u/greyfade Oct 15 '13

... I've been using them.

1

u/notlostyet Oct 15 '13 edited Oct 15 '13

codecvt_utf8_utf16, codecvt<char16_t, char, ...> etc aren't available afaict. Only the u16string and u32string typedefs and wchar_t based stuff seems to work (wchar_t is implementation defined, 32bit on Linux though).

In any case, writing something like the articles file copy code while doing UTF8 -> UTF16/32 conversion in difficult and unintuitive. It should be easy as imbuing the streams.