qt - Get QString length in bytes (not characters) -
i need solve problem opposite this one. have qstring non-ascii symbols.
example:
schöne grüße
how length of string in bytes utf8 case? should 15.
have tried conversion bytearray
, latin1
, ascii
length same.
you need use ::toutf8() , append qbytearray. can length using .size().
qstring s = "schöne grüße"; qbytearray bytes = s.toutf8(); int length = bytes.size(); //number of bytes
Comments
Post a Comment