diff options
author | Gerald Combs <gerald@wireshark.org> | 2017-12-14 10:29:48 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2017-12-14 20:26:52 +0000 |
commit | db740987fffeb7e8122a6cd40e25f16244af5721 (patch) | |
tree | 3b0a6831fefe8c7e13be9d0f01a1916a413aaffe /docbook/wsdg_src | |
parent | 4cf7cd3ed20c57dc5977be5be37ced0bd1706d61 (diff) |
Qt: Add and use qUtf8Printable.
Qt 5.4 introduced qUtf8Printable, a convenience macro for converting
QString to a UTF-8 const char *. Add a compatibility definition and
start using it.
Change-Id: I3cf88611b1ed1a34082cb2ba82394954e2e6c461
Reviewed-on: https://code.wireshark.org/review/24828
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'docbook/wsdg_src')
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_userinterface.asciidoc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/docbook/wsdg_src/WSDG_chapter_userinterface.asciidoc b/docbook/wsdg_src/WSDG_chapter_userinterface.asciidoc index fd906a3ada..ce2a070a63 100644 --- a/docbook/wsdg_src/WSDG_chapter_userinterface.asciidoc +++ b/docbook/wsdg_src/WSDG_chapter_userinterface.asciidoc @@ -163,12 +163,19 @@ it's not strictly required: ===== Strings -If you're using GLib string functions or plain old C character array idioms in -Qt-only code you're probably doing something wrong. QStrings are generally -*much* safer and easier to use. They also make translations easier. +Wireshark's C code and GLib use UTF-8 encoded character arrays. Qt +(specifically QString) uses UTF-16. You can convert a `char *` to a +`QString` using simple assignment. You can convert a `QString` to a +`const char *` using `qUtf8Printable`. + +If you're using GLib string functions or plain old C character array +idioms in Qt-only code you're probably doing something wrong, +particularly if you're manually allocating and releasing memory. +QStrings are generally *much* safer and easier to use. They also make +translations easier. If you need to pass strings between Qt and GLib you can use a number -of convenience routines which are defined in 'ui/qt/qt_ui_utils.h'. +of convenience routines which are defined in 'ui/qt/qt_ui_utils.h'. If you're calling a function that returns wmem-allocated memory it might make more sense to add a wrapper function to 'qt_ui_utils' than to call wmem_free in |