Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On 19/03/12 09:50, Enrico Weigelt wrote:
Hi folks,


I just went into this list and wonder why lo has its own string
implementation instead of using std::string. Could anyone
please give me some insight ?

the historical reason is that std::string is part of the C++ standard
library, and implementations of that generally only started to become
actually usable on all platforms in the early 2000s.

the other reason is that std::string isn't particularly well suited to
storing Unicode, because all of the operations on it are defined in
terms of elements of an array.  so when using std::string accessing
UTF-8 characters is both cumbersome and error-prone, while using
std::wstring is not an option at all because it is based on wchar_t, and
the geniuses didn't define whether that is 16bit or 32bit, so it's
_completely_ useless in practice.  the only option really would be to
use something like std;:basic_string<uint32_t>, but that wastes a lot of
space in the common case, or std::basic_string<uint16_t>, which is just
as stupid as our existing rtl::OUString.

hmm... what i'd really like from a string class is that it has no
operator[] at all (who needs that anyway), just an iterator interface
that returns characters as uint32_t, and another interface to write the
string UTF-8 encoded into some buffer, thus allowing for picking
whatever internal implementation is most suitable.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.