aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/encoding.cpp12
-rw-r--r--common/encoding.h4
2 files changed, 14 insertions, 2 deletions
diff --git a/common/encoding.cpp b/common/encoding.cpp
index e0446c0d27..f9dd19395d 100644
--- a/common/encoding.cpp
+++ b/common/encoding.cpp
@@ -55,6 +55,18 @@ void Encoding::deinitIconv(iconv_t iconvHandle) {
#endif // USE_ICONV
}
+void Encoding::setFrom(const String &from) {
+ deinitIconv(_iconvHandle);
+ _from = from;
+ _iconvHandle = initIconv(_to, _from);
+}
+
+void Encoding::setTo(const String &to) {
+ deinitIconv(_iconvHandle);
+ _to = to;
+ _iconvHandle = initIconv(_to, _from);
+}
+
char *Encoding::convert(const char *string, size_t size) {
return conversion(_iconvHandle, _to, _from, string, size);
}
diff --git a/common/encoding.h b/common/encoding.h
index b55c485efd..67c5ac68ca 100644
--- a/common/encoding.h
+++ b/common/encoding.h
@@ -93,7 +93,7 @@ class Encoding {
/**
* @param from The encoding, to convert from
*/
- void setFrom(const String &from) {_from = from;};
+ void setFrom(const String &from);
/**
* @return The encoding, which is currently being converted to
@@ -103,7 +103,7 @@ class Encoding {
/**
* @param to The encoding, to convert to
*/
- void setTo(const String &to) {_to = to;};
+ void setTo(const String &to);
private:
/** The encoding, which is currently being converted to */