[glom] Fix potential encoding error for currency symbols
- From: Michael Hasselmann <mikhas src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Fix potential encoding error for currency symbols
- Date: Fri, 8 Jan 2010 10:38:00 +0000 (UTC)
commit 9503cc76b0415bbdebce286af77167282499ee99
Author: Michael Hasselmann <michaelh openismus com>
Date: Thu Jan 7 19:39:22 2010 +0100
Fix potential encoding error for currency symbols
* glom/libglom/data_structure/glomconversions.cc (get_text_for_gda_value):
Glom's numeric type can be prefixed with a currency symbol. If the symbol
cannot be represented in the user's locale it would hide all data for the
column. This is fixed by using a fallback conversion for the symbol.
Fixes bug #606349.
ChangeLog | 10 ++++++++++
glom/libglom/data_structure/glomconversions.cc | 11 ++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9f8ab9d..5763258 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-01-07 Michael Hasselmann <michaelh openismus com>
+
+ Fix potential encoding error for currency symbols
+
+ * glom/libglom/data_structure/glomconversions.cc (get_text_for_gda_value):
+ Glom's numeric type can be prefixed with a currency symbol. If the symbol
+ cannot be represented in the user's locale it would hide all data for the
+ column. This is fixed by using a fallback conversion for the symbol.
+ Fixes bug #606349.
+
2010-01-07 Armin Burgmeier <armin arbur net>
* win32/build-installer:
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index 6d017bc..95a0fe5 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -436,7 +436,16 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
if(!(numeric_format.m_currency_symbol.empty()))
{
- another_stream << numeric_format.m_currency_symbol << " ";
+ std::string charset;
+ Glib::get_charset(charset);
+ Glib::ustring currency_symbol = Glib::convert_with_fallback(numeric_format.m_currency_symbol, charset, "UTF-8");
+ // Uses convert_with_fallback(.) for the curreny symbol to avoid an
+ // exception where the operator<<'s automatic conversion fails.
+ // Incompatible encodings are possible since the currency symbol itself
+ // is stored in the Glom document (UTF-8), whereas the stream encoding
+ // depends on the user's locale (needed for the numeric value
+ // representation).
+ another_stream << currency_symbol << " ";
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]