On Sat, 24 Jun 2017 19:08:36 +0100
Chris Vine <vine35792...@gmail.com> wrote:

> On Sat, 24 Jun 2017 15:51:49 +0100
> Daniel Boles <dboles....@gmail.com> wrote:
> > Title says it all really. I had to use an std::string in one place
> > because I needed to modify it quickly and with less hassle than
> > using .replace() - and Glib::ustring won't let me get a reference to
> > perform such modification.
> > 
> > The documentation states
> >     "No reference return; use replace()
> > <https://developer.gnome.org/glibmm/stable/classGlib_1_1ustring.html#a0f0c9b5aaad58279d3ac87a86a173f4a>
> > to write characters."
> > but does not explain why, nor does the commit log: these comments
> > were added way back in the initial revision.
> > 
> > So I'm wondering whether there's really a reason for this, or if it
> > is just something that no one has wanted to change (until now!)  
> 
> It is because UTF-8 is a multibyte encoding, and any one character may
> require between 1 and 5 bytes to represent it.  If you were allowed to
> change a byte at will you would be able to introduce invalid encoding
> sequences.  As to the absense of documentation, maybe it is because
> this was thought to be self-evident, dunno.

And I should perhaps also make the point that these operators return a
32-bit unicode character, not a byte, which is consequent on the same
point.  If you allowed mutation, the length of the string (in bytes)
might change.
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to