Re: [Gnome-bindings] Strings and bindings



Owen Taylor <otaylor redhat com> writes:

> C++
> ===

[...]

> There are at least three ways I can think of to handle 
> GTK+'s utf-8 strings in Unicode:
> 
>  - convert them to wstring
> 
>  - convert them to basic_string<gunichar> 
>  
>    that is, avoid the problem of the unspecified width, by
>    defining a new string type using a type of specified
>    width.
> 
>  - Create an STL-string-like wrapper for a utf8 string. The
>    problem here is that you don't get O(1) random access, which
>    will no doubt disturb some of the people reading this.

If simply reusing wstring is an option, then I suggest we do. No need
to define new types if we can avoid it, plus it makes interoperability
with the rest of the world easier.

> If one did use the standard STL wstring type, then one would
> run into the problem that there will be no 
> 
>  wstring (const char *eightbit_string);
> 
> constructor so you would probably have to subclass it to add
> that converter in any case. But I'm not enough of a C++ expert
> to really comment.

I'm not sure what you mean here. Is eightbit_string in utf8 ? There is 
a wstring (const char *); ctor defined.

> So, the question is, do we need two types in the type system for
> user-visible and non-user-visible strings or just one? My default
> answer is that we should keep it simple, and just have one, but I'm
> very willing to accept input on this issue.

I'd go for simplicity as well here.

-- 
					Guillaume.
					http://www.telegraph-road.org




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]