[PATCH v2] Use UTF-8 for text strings.
Michael Andreen
harv at ruin.nu
Mon Dec 16 14:50:42 UTC 2013
Fixes #371
Signed-off-by: Michael Andreen <harv at ruin.nu>
---
On Monday, December 16, 2013 02:18:18 PM Thiago Macieira wrote:
> While the patch itself is fine, I'm not sure it's actually fixing anything.
> Michael, can you confirm that it does fix the problem?
>
> The reason being that we set the "codec for C strings" early in the
> initialisation, so
>
> QString(text) == QString::fromUtf8(text)
So I went a bit far with all the fromUtf8. The actual problem is just
toLocal8Bit(). I managed to reproduce the problem on linux by using a latin1
locale for LC_CTYPE and switching to toUtf8() fixes the problem.
qt-ui/maintab.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 82e5d2e..b2185fd 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -687,12 +687,12 @@ void MainTab::resetPallete()
}
#define EDIT_TEXT2(what, text) \
- textByteArray = text.toLocal8Bit(); \
+ textByteArray = text.toUtf8(); \
free(what);\
what = strdup(textByteArray.data());
#define EDIT_TEXT(what, text) \
- QByteArray textByteArray = text.toLocal8Bit(); \
+ QByteArray textByteArray = text.toUtf8(); \
free(what);\
what = strdup(textByteArray.data());
@@ -976,8 +976,8 @@ QString MainTab::printGPSCoords(int lat, int lon)
ilatmin = (lat % 1000000) * 60;
ilonmin = (lon % 1000000) * 60;
result.sprintf("%s%u%s %2d.%05d\' , %s%u%s %2d.%05d\'",
- lath.toLocal8Bit().data(), latdeg, UTF8_DEGREE, ilatmin / 1000000, (ilatmin % 1000000) / 10,
- lonh.toLocal8Bit().data(), londeg, UTF8_DEGREE, ilonmin / 1000000, (ilonmin % 1000000) / 10);
+ lath.toUtf8().data(), latdeg, UTF8_DEGREE, ilatmin / 1000000, (ilatmin % 1000000) / 10,
+ lonh.toUtf8().data(), londeg, UTF8_DEGREE, ilonmin / 1000000, (ilonmin % 1000000) / 10);
return result;
}
--
1.8.3.2
More information about the subsurface
mailing list