12

Which one to use, utf8 or Ascii

 4 years ago
source link: https://www.codesd.com/item/which-one-to-use-utf8-or-ascii.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Which one to use, utf8 or Ascii

advertisements

Been doing quite a lot of work with Qt and it just hit me, which one should I use to convert my QStrings to QByteArray and back? And there is some other issues where I dont know what to do exactly.

For example when dealing with QUrl. I have an object where on of the members are a QString and I'm setting it like this:

blobByType->setBlobAbsoluteUri(request.url().toEncoded());

The toEncoded() converts it to utf8 and and all non-ASCII characters are then percent encode. When I then set the QString to a QByteArray it automatically converts it Ascii.

Also, when doing most of my converting from QString to QByteArray I currently use toUtf8().

My question is, what should I use when converting from QString to QByteArray and vice versa?


If there is a chance that you are going to use non-english characters it's better to use UTF-8. It's standard and good practice to use it because you never know who might be reusing your code in the future.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK