aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-01-07 13:50:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-01-07 13:50:11 +0200
commit76d23e639004517db8f9469d64ac1789f8449365 (patch)
treedbafc8c4e31a97f74046c98af19d0fe76f360001
parentc30caae30bc64974eeaa1e81aa2abdc203f5120d (diff)
Add support for ISO-8859-1 as application encoding
New runtime configuration parameter, XSDE_ENCODING. New option, --char-encoding. New test, tests/cxx/hybrid/iso8859-1.
-rw-r--r--NEWS11
-rw-r--r--build/configuration.make2
-rwxr-xr-xbuild/configure10
-rwxr-xr-xbuild/dist4
-rw-r--r--build/xsde/hybrid/xsd-cxx.make1
-rw-r--r--build/xsde/parser/xsd-cxx.make2
-rw-r--r--build/xsde/serializer/xsd-cxx.make2
-rw-r--r--dist/build/config.make1
-rw-r--r--dist/config/config.make18
-rw-r--r--dist/config/config.nmake14
-rw-r--r--dist/etc/evc-4.0/config.nmake14
-rw-r--r--dist/etc/iphone/config-device.make14
-rw-r--r--dist/etc/iphone/config-simulator.make14
-rw-r--r--dist/etc/lynxos/config-4.2.make14
-rw-r--r--dist/etc/lynxos/config-5.0.make14
-rw-r--r--dist/etc/qnx/config-6.3-gcc-2.95.make14
-rw-r--r--dist/etc/qnx/config-6.3-gcc-3.3.make14
-rw-r--r--dist/etc/qnx/config-6.4.make14
-rw-r--r--dist/etc/vc-8.0/config-max.nmake14
-rw-r--r--dist/etc/vc-8.0/config-min.nmake14
-rw-r--r--dist/etc/vc-9.0/config-max.nmake14
-rw-r--r--dist/etc/vc-9.0/config-min.nmake14
-rw-r--r--dist/etc/vxworks/config-5.5.1.make14
-rw-r--r--dist/etc/vxworks/config-6.4-max.make14
-rw-r--r--dist/etc/vxworks/config-6.4-min.make14
-rw-r--r--dist/etc/vxworks/config-6.7-max.make14
-rw-r--r--dist/etc/vxworks/config-6.7-min.make14
-rw-r--r--dist/examples/cxx/hybrid/binary/cdr/makefile4
-rw-r--r--dist/examples/cxx/hybrid/binary/cdr/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/binary/custom/makefile4
-rw-r--r--dist/examples/cxx/hybrid/binary/custom/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/binary/xdr/makefile4
-rw-r--r--dist/examples/cxx/hybrid/binary/xdr/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/compositors/makefile4
-rw-r--r--dist/examples/cxx/hybrid/compositors/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/custom/wildcard/makefile4
-rw-r--r--dist/examples/cxx/hybrid/custom/wildcard/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/filter/makefile4
-rw-r--r--dist/examples/cxx/hybrid/filter/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/hello/makefile4
-rw-r--r--dist/examples/cxx/hybrid/hello/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/library/makefile4
-rw-r--r--dist/examples/cxx/hybrid/library/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/minimal/makefile4
-rw-r--r--dist/examples/cxx/hybrid/minimal/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/multiroot/makefile4
-rw-r--r--dist/examples/cxx/hybrid/multiroot/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/polymorphism/makefile4
-rw-r--r--dist/examples/cxx/hybrid/polymorphism/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/polyroot/makefile4
-rw-r--r--dist/examples/cxx/hybrid/polyroot/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/streaming/makefile4
-rw-r--r--dist/examples/cxx/hybrid/streaming/nmakefile4
-rw-r--r--dist/examples/cxx/hybrid/wildcard/makefile4
-rw-r--r--dist/examples/cxx/hybrid/wildcard/nmakefile4
-rw-r--r--dist/examples/cxx/parser/generated/makefile4
-rw-r--r--dist/examples/cxx/parser/generated/nmakefile4
-rw-r--r--dist/examples/cxx/parser/hello/makefile4
-rw-r--r--dist/examples/cxx/parser/hello/nmakefile4
-rw-r--r--dist/examples/cxx/parser/library/makefile4
-rw-r--r--dist/examples/cxx/parser/library/nmakefile4
-rw-r--r--dist/examples/cxx/parser/minimal/makefile4
-rw-r--r--dist/examples/cxx/parser/minimal/nmakefile4
-rw-r--r--dist/examples/cxx/parser/mixed/makefile4
-rw-r--r--dist/examples/cxx/parser/mixed/nmakefile4
-rw-r--r--dist/examples/cxx/parser/multiroot/makefile4
-rw-r--r--dist/examples/cxx/parser/multiroot/nmakefile4
-rw-r--r--dist/examples/cxx/parser/polymorphism/makefile4
-rw-r--r--dist/examples/cxx/parser/polymorphism/nmakefile4
-rw-r--r--dist/examples/cxx/parser/polyroot/makefile4
-rw-r--r--dist/examples/cxx/parser/polyroot/nmakefile4
-rw-r--r--dist/examples/cxx/parser/wildcard/makefile4
-rw-r--r--dist/examples/cxx/parser/wildcard/nmakefile4
-rw-r--r--dist/examples/cxx/serializer/hello/makefile4
-rw-r--r--dist/examples/cxx/serializer/hello/nmakefile4
-rw-r--r--dist/examples/cxx/serializer/library/makefile4
-rw-r--r--dist/examples/cxx/serializer/library/nmakefile4
-rw-r--r--dist/examples/cxx/serializer/minimal/makefile4
-rw-r--r--dist/examples/cxx/serializer/minimal/nmakefile4
-rw-r--r--dist/examples/cxx/serializer/polymorphism/makefile4
-rw-r--r--dist/examples/cxx/serializer/polymorphism/nmakefile4
-rw-r--r--dist/examples/cxx/serializer/polyroot/makefile4
-rw-r--r--dist/examples/cxx/serializer/polyroot/nmakefile4
-rw-r--r--dist/examples/cxx/serializer/wildcard/makefile4
-rw-r--r--dist/examples/cxx/serializer/wildcard/nmakefile4
-rw-r--r--dist/libxsde/xsde/makefile18
-rw-r--r--dist/libxsde/xsde/nmakefile18
-rw-r--r--dist/tests/cxx/hybrid/makefile4
-rw-r--r--dist/tests/cxx/hybrid/nmakefile4
-rw-r--r--documentation/cxx/hybrid/guide/index.xhtml37
-rw-r--r--documentation/cxx/parser/guide/index.xhtml23
-rw-r--r--documentation/cxx/serializer/guide/index.xhtml11
-rw-r--r--documentation/xsde.113
-rw-r--r--documentation/xsde.xhtml11
-rw-r--r--libxsde/xsde/cxx/iso8859-1.cxx170
-rw-r--r--libxsde/xsde/cxx/iso8859-1.hxx85
-rw-r--r--libxsde/xsde/cxx/iso8859-1.ixx128
-rw-r--r--libxsde/xsde/cxx/parser/expat/document.cxx375
-rw-r--r--libxsde/xsde/cxx/parser/expat/document.hxx21
-rw-r--r--libxsde/xsde/cxx/parser/expat/document.ixx1
-rw-r--r--libxsde/xsde/cxx/parser/expat/xml-error.cxx10
-rw-r--r--libxsde/xsde/cxx/parser/expat/xml-error.hxx10
-rw-r--r--libxsde/xsde/cxx/serializer/context.cxx702
-rw-r--r--libxsde/xsde/cxx/serializer/context.hxx18
-rw-r--r--libxsde/xsde/cxx/serializer/context.ixx274
-rw-r--r--libxsde/xsde/makefile14
-rw-r--r--tests/cxx/hybrid/iso8859-1/driver.cxx95
-rw-r--r--tests/cxx/hybrid/iso8859-1/makefile108
-rw-r--r--tests/cxx/hybrid/iso8859-1/test-000.std1
-rw-r--r--tests/cxx/hybrid/iso8859-1/test-000.xml15
-rw-r--r--tests/cxx/hybrid/iso8859-1/test.xsd23
-rw-r--r--tests/cxx/hybrid/makefile6
-rw-r--r--xsde/cxx/elements.cxx130
-rw-r--r--xsde/cxx/elements.hxx29
-rw-r--r--xsde/cxx/hybrid/cli.hxx2
-rw-r--r--xsde/cxx/hybrid/elements.cxx1
-rw-r--r--xsde/cxx/hybrid/generator.cxx38
-rw-r--r--xsde/cxx/hybrid/parser-name-processor.cxx1
-rw-r--r--xsde/cxx/hybrid/serializer-name-processor.cxx1
-rw-r--r--xsde/cxx/hybrid/tree-name-processor.cxx1
-rw-r--r--xsde/cxx/hybrid/tree-type-map.cxx1
-rw-r--r--xsde/cxx/hybrid/validator.cxx12
-rw-r--r--xsde/cxx/parser/cli.hxx2
-rw-r--r--xsde/cxx/parser/elements.cxx1
-rw-r--r--xsde/cxx/parser/generator.cxx36
-rw-r--r--xsde/cxx/parser/name-processor.cxx1
-rw-r--r--xsde/cxx/parser/parser-header.cxx16
-rw-r--r--xsde/cxx/parser/validator.cxx10
-rw-r--r--xsde/cxx/serializer/cli.hxx2
-rw-r--r--xsde/cxx/serializer/elements.cxx1
-rw-r--r--xsde/cxx/serializer/generator.cxx36
-rw-r--r--xsde/cxx/serializer/name-processor.cxx1
-rw-r--r--xsde/cxx/serializer/validator.cxx10
133 files changed, 2744 insertions, 318 deletions
diff --git a/NEWS b/NEWS
index 323ea50..c03870c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,17 @@ Version 3.2.0
* Automatic mapping for the urn-style XML namespaces. The last component
in the urn name is used to derive the C++ namespace name.
+ * Support for ISO-8859-1 in addition to UTF-8 as application encoding.
+ Note that this encoding is not the same as the XML document encoding
+ that is being parsed or serialized. Rather, it is the encoding that
+ is used inside the application. When an XML document is parsed the
+ character data is automatically converted to the application encoding.
+ Similarly, when an XML document is serialized, the data in the
+ application encoding is automatically converted to the resulting
+ document encoding. To select a particular encoding, configure the
+ XSD/e runtime library accordingly and pass the --char-encoding option
+ to the XSD/e compiler when translating your schemas.
+
C++/Hybrid
* String-based types that use XML Schema restriction by enumeration are
diff --git a/build/configuration.make b/build/configuration.make
index 05318c9..49624e5 100644
--- a/build/configuration.make
+++ b/build/configuration.make
@@ -10,6 +10,7 @@ $(call include-once,$(scf_root)/configuration-rules.make,$(dcf_root))
#
xsde_arch_width :=
xsde_byteorder :=
+xsde_encoding :=
xsde_stl :=
xsde_stl_iterator :=
xsde_iostream :=
@@ -35,6 +36,7 @@ ifdef xsde_stl
$(out_root)/%: xsde_arch_width := $(xsde_arch_width)
$(out_root)/%: xsde_byteorder := $(xsde_byteorder)
+$(out_root)/%: xsde_encoding := $(xsde_encoding)
$(out_root)/%: xsde_stl := $(xsde_stl)
$(out_root)/%: xsde_stl_iterator := $(xsde_stl_iterator)
$(out_root)/%: xsde_iostream := $(xsde_iostream)
diff --git a/build/configure b/build/configure
index e49a7c5..8295e76 100755
--- a/build/configure
+++ b/build/configure
@@ -39,6 +39,15 @@ else
fi
$echo
+$echo "Please select the application character encoding:"
+$echo
+$echo "(1) UTF-8"
+$echo "(2) ISO-8859-1"
+$echo
+
+encoding=`read_option "utf8 iso8859-1" "utf8"`
+
+$echo
$echo "Would you like the generated code and runtime to use STL?"
$echo
@@ -166,6 +175,7 @@ fi
echo "xsde_arch_width := $arch_width" >$1
echo "xsde_byteorder := $byteorder" >>$1
+echo "xsde_encoding := $encoding" >>$1
echo "xsde_stl := $stl" >>$1
echo "xsde_stl_iterator := $stl_iter" >>$1
echo "xsde_iostream := $iostream" >>$1
diff --git a/build/dist b/build/dist
index eb74acc..cbb9678 100755
--- a/build/dist
+++ b/build/dist
@@ -208,6 +208,8 @@ if [ "$lib" != "" ]; then
gen
fi
+gen 'EXTRA_XSDFLAGS += --char-encoding $(XSDE_ENCODING)'
+gen
gen 'ifeq ($(XSDE_STL),n)'
gen 'EXTRA_XSDFLAGS += --no-stl'
gen 'endif'
@@ -357,6 +359,8 @@ if [ "$lib" != "" ]; then
gen
fi
+gen 'EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding $(XSDE_ENCODING)'
+gen
gen '!if "$(XSDE_STL)" == "n"'
gen 'EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl'
gen '!endif'
diff --git a/build/xsde/hybrid/xsd-cxx.make b/build/xsde/hybrid/xsd-cxx.make
index c026291..540fa1f 100644
--- a/build/xsde/hybrid/xsd-cxx.make
+++ b/build/xsde/hybrid/xsd-cxx.make
@@ -56,6 +56,7 @@ ops := \
--sskel-file-suffix $(xsd_sskel_suffix) \
--simpl-file-suffix $(xsd_simpl_suffix)
+ops += --char-encoding $(xsde_encoding)
ifeq ($(xsde_stl),n)
ops += --no-stl
diff --git a/build/xsde/parser/xsd-cxx.make b/build/xsde/parser/xsd-cxx.make
index cd657d6..f9c87e9 100644
--- a/build/xsde/parser/xsd-cxx.make
+++ b/build/xsde/parser/xsd-cxx.make
@@ -34,6 +34,8 @@ ifneq ($(xsd_pimpl_suffix),)
ops += --impl-file-suffix $(xsd_pimpl_suffix)
endif
+ops += --char-encoding $(xsde_encoding)
+
ifeq ($(xsde_stl),n)
ops += --no-stl
endif
diff --git a/build/xsde/serializer/xsd-cxx.make b/build/xsde/serializer/xsd-cxx.make
index 2f57782..a042ef9 100644
--- a/build/xsde/serializer/xsd-cxx.make
+++ b/build/xsde/serializer/xsd-cxx.make
@@ -34,6 +34,8 @@ ifneq ($(xsd_pimpl_suffix),)
ops += --impl-file-suffix $(xsd_simpl_suffix)
endif
+ops += --char-encoding $(xsde_encoding)
+
ifeq ($(xsde_stl),n)
ops += --no-stl
endif
diff --git a/dist/build/config.make b/dist/build/config.make
index 87a39c6..b05df1a 100644
--- a/dist/build/config.make
+++ b/dist/build/config.make
@@ -14,6 +14,7 @@ include $(root)/config/config.make
XSDE_PLATFORM := $(strip $(XSDE_PLATFORM))
XSDE_ARCH_WIDTH := $(strip $(XSDE_ARCH_WIDTH))
XSDE_BYTEORDER := $(strip $(XSDE_BYTEORDER))
+XSDE_ENCODING := $(strip $(XSDE_ENCODING))
XSDE_STL := $(strip $(XSDE_STL))
XSDE_IOSTREAM := $(strip $(XSDE_IOSTREAM))
XSDE_EXCEPTIONS := $(strip $(XSDE_EXCEPTIONS))
diff --git a/dist/config/config.make b/dist/config/config.make
index ac3518c..fccb68f 100644
--- a/dist/config/config.make
+++ b/dist/config/config.make
@@ -37,12 +37,26 @@ XSDE_PLATFORM := posix
XSDE_ARCH_WIDTH := 32
-# Platform byte order. Valid values are 'b' for big-endian
-# and 'l' for little-endian.
+# Platform byte order. Valid values are 'b' for big-endian and 'l'
+# for little-endian.
#
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/config/config.nmake b/dist/config/config.nmake
index 599d660..0e4008f 100644
--- a/dist/config/config.nmake
+++ b/dist/config/config.nmake
@@ -42,6 +42,20 @@ XSDE_ARCH_WIDTH = 32
XSDE_BYTEORDER = l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING = utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/evc-4.0/config.nmake b/dist/etc/evc-4.0/config.nmake
index cb4777f..136f281 100644
--- a/dist/etc/evc-4.0/config.nmake
+++ b/dist/etc/evc-4.0/config.nmake
@@ -45,6 +45,20 @@ XSDE_ARCH_WIDTH = 32
XSDE_BYTEORDER = l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING = utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/iphone/config-device.make b/dist/etc/iphone/config-device.make
index a52c484..c6e8634 100644
--- a/dist/etc/iphone/config-device.make
+++ b/dist/etc/iphone/config-device.make
@@ -50,6 +50,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/iphone/config-simulator.make b/dist/etc/iphone/config-simulator.make
index 3ab24df..afff0a6 100644
--- a/dist/etc/iphone/config-simulator.make
+++ b/dist/etc/iphone/config-simulator.make
@@ -50,6 +50,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/lynxos/config-4.2.make b/dist/etc/lynxos/config-4.2.make
index beb401e..5be4262 100644
--- a/dist/etc/lynxos/config-4.2.make
+++ b/dist/etc/lynxos/config-4.2.make
@@ -49,6 +49,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/lynxos/config-5.0.make b/dist/etc/lynxos/config-5.0.make
index 3c64855..25a15b2 100644
--- a/dist/etc/lynxos/config-5.0.make
+++ b/dist/etc/lynxos/config-5.0.make
@@ -49,6 +49,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/qnx/config-6.3-gcc-2.95.make b/dist/etc/qnx/config-6.3-gcc-2.95.make
index 4a6bb1b..3211450 100644
--- a/dist/etc/qnx/config-6.3-gcc-2.95.make
+++ b/dist/etc/qnx/config-6.3-gcc-2.95.make
@@ -48,6 +48,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/qnx/config-6.3-gcc-3.3.make b/dist/etc/qnx/config-6.3-gcc-3.3.make
index 770693b..e0a84db 100644
--- a/dist/etc/qnx/config-6.3-gcc-3.3.make
+++ b/dist/etc/qnx/config-6.3-gcc-3.3.make
@@ -48,6 +48,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/qnx/config-6.4.make b/dist/etc/qnx/config-6.4.make
index a302d0d..71f40db 100644
--- a/dist/etc/qnx/config-6.4.make
+++ b/dist/etc/qnx/config-6.4.make
@@ -48,6 +48,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vc-8.0/config-max.nmake b/dist/etc/vc-8.0/config-max.nmake
index 07b46bb..59d1a1c 100644
--- a/dist/etc/vc-8.0/config-max.nmake
+++ b/dist/etc/vc-8.0/config-max.nmake
@@ -46,6 +46,20 @@ XSDE_ARCH_WIDTH = 32
XSDE_BYTEORDER = l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING = utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vc-8.0/config-min.nmake b/dist/etc/vc-8.0/config-min.nmake
index 286e349..bdb9863 100644
--- a/dist/etc/vc-8.0/config-min.nmake
+++ b/dist/etc/vc-8.0/config-min.nmake
@@ -46,6 +46,20 @@ XSDE_ARCH_WIDTH = 32
XSDE_BYTEORDER = l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING = utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vc-9.0/config-max.nmake b/dist/etc/vc-9.0/config-max.nmake
index 938bc3d..3a11fe7 100644
--- a/dist/etc/vc-9.0/config-max.nmake
+++ b/dist/etc/vc-9.0/config-max.nmake
@@ -46,6 +46,20 @@ XSDE_ARCH_WIDTH = 32
XSDE_BYTEORDER = l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING = utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vc-9.0/config-min.nmake b/dist/etc/vc-9.0/config-min.nmake
index b98e9a9..9df85b5 100644
--- a/dist/etc/vc-9.0/config-min.nmake
+++ b/dist/etc/vc-9.0/config-min.nmake
@@ -46,6 +46,20 @@ XSDE_ARCH_WIDTH = 32
XSDE_BYTEORDER = l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING = utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vxworks/config-5.5.1.make b/dist/etc/vxworks/config-5.5.1.make
index 9d6d8c5..89bf164 100644
--- a/dist/etc/vxworks/config-5.5.1.make
+++ b/dist/etc/vxworks/config-5.5.1.make
@@ -49,6 +49,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := b
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vxworks/config-6.4-max.make b/dist/etc/vxworks/config-6.4-max.make
index 0d7ba41..b1b08fd 100644
--- a/dist/etc/vxworks/config-6.4-max.make
+++ b/dist/etc/vxworks/config-6.4-max.make
@@ -61,6 +61,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vxworks/config-6.4-min.make b/dist/etc/vxworks/config-6.4-min.make
index 3efd917..3435c70 100644
--- a/dist/etc/vxworks/config-6.4-min.make
+++ b/dist/etc/vxworks/config-6.4-min.make
@@ -48,6 +48,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vxworks/config-6.7-max.make b/dist/etc/vxworks/config-6.7-max.make
index f6e8674..43731df 100644
--- a/dist/etc/vxworks/config-6.7-max.make
+++ b/dist/etc/vxworks/config-6.7-max.make
@@ -61,6 +61,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/etc/vxworks/config-6.7-min.make b/dist/etc/vxworks/config-6.7-min.make
index 42861a3..cf8d622 100644
--- a/dist/etc/vxworks/config-6.7-min.make
+++ b/dist/etc/vxworks/config-6.7-min.make
@@ -48,6 +48,20 @@ XSDE_ARCH_WIDTH := 32
XSDE_BYTEORDER := l
+# Application character encoding. Valid values are 'utf8' for UTF-8
+# and 'iso8859-1' for ISO-8859-1. Note that this encoding is not
+# the same as the XML document encoding that is being parsed or
+# serialized. Rather, it is the encoding that is used inside the
+# application. When an XML document is parsed, the character data
+# is automatically converted to the application encoding. Similarly,
+# when an XML document is serialized, the data in the application
+# encoding is automatically converted to the resulting document
+# encoding. Also don't forget to use the --char-encoding option
+# when compiling your schemas if using an encoding other than UTF-8.
+#
+XSDE_ENCODING := utf8
+
+
# Set to 'n' if you don't have STL (std::string, etc.). Also don't
# forget to use the --no-stl option when compiling your schemas.
#
diff --git a/dist/examples/cxx/hybrid/binary/cdr/makefile b/dist/examples/cxx/hybrid/binary/cdr/makefile
index 1453f78..9e0cd7d 100644
--- a/dist/examples/cxx/hybrid/binary/cdr/makefile
+++ b/dist/examples/cxx/hybrid/binary/cdr/makefile
@@ -8,6 +8,10 @@ override LIBS += -lACE
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/binary/cdr/nmakefile b/dist/examples/cxx/hybrid/binary/cdr/nmakefile
index ce9210b..ffa65b6 100644
--- a/dist/examples/cxx/hybrid/binary/cdr/nmakefile
+++ b/dist/examples/cxx/hybrid/binary/cdr/nmakefile
@@ -8,6 +8,10 @@ LIBS = $(LIBS) ACE.lib
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/binary/custom/makefile b/dist/examples/cxx/hybrid/binary/custom/makefile
index 9d02861..55f1944 100644
--- a/dist/examples/cxx/hybrid/binary/custom/makefile
+++ b/dist/examples/cxx/hybrid/binary/custom/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/binary/custom/nmakefile b/dist/examples/cxx/hybrid/binary/custom/nmakefile
index 00a0964..02e193f 100644
--- a/dist/examples/cxx/hybrid/binary/custom/nmakefile
+++ b/dist/examples/cxx/hybrid/binary/custom/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/binary/xdr/makefile b/dist/examples/cxx/hybrid/binary/xdr/makefile
index 257536d..ebd0241 100644
--- a/dist/examples/cxx/hybrid/binary/xdr/makefile
+++ b/dist/examples/cxx/hybrid/binary/xdr/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/binary/xdr/nmakefile b/dist/examples/cxx/hybrid/binary/xdr/nmakefile
index 332bbeb..49cbbb2 100644
--- a/dist/examples/cxx/hybrid/binary/xdr/nmakefile
+++ b/dist/examples/cxx/hybrid/binary/xdr/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/compositors/makefile b/dist/examples/cxx/hybrid/compositors/makefile
index dd36b46..beda699 100644
--- a/dist/examples/cxx/hybrid/compositors/makefile
+++ b/dist/examples/cxx/hybrid/compositors/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/compositors/nmakefile b/dist/examples/cxx/hybrid/compositors/nmakefile
index 14039ac..3178b0a 100644
--- a/dist/examples/cxx/hybrid/compositors/nmakefile
+++ b/dist/examples/cxx/hybrid/compositors/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/custom/wildcard/makefile b/dist/examples/cxx/hybrid/custom/wildcard/makefile
index fb85b48..f316afa 100644
--- a/dist/examples/cxx/hybrid/custom/wildcard/makefile
+++ b/dist/examples/cxx/hybrid/custom/wildcard/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/hybrid/custom/wildcard/nmakefile b/dist/examples/cxx/hybrid/custom/wildcard/nmakefile
index 329c993..37f1293 100644
--- a/dist/examples/cxx/hybrid/custom/wildcard/nmakefile
+++ b/dist/examples/cxx/hybrid/custom/wildcard/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/hybrid/filter/makefile b/dist/examples/cxx/hybrid/filter/makefile
index 586a166..baf45ce 100644
--- a/dist/examples/cxx/hybrid/filter/makefile
+++ b/dist/examples/cxx/hybrid/filter/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/hybrid/filter/nmakefile b/dist/examples/cxx/hybrid/filter/nmakefile
index 6db5615..d535457 100644
--- a/dist/examples/cxx/hybrid/filter/nmakefile
+++ b/dist/examples/cxx/hybrid/filter/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/hybrid/hello/makefile b/dist/examples/cxx/hybrid/hello/makefile
index 5499a21..9b2130d 100644
--- a/dist/examples/cxx/hybrid/hello/makefile
+++ b/dist/examples/cxx/hybrid/hello/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/hello/nmakefile b/dist/examples/cxx/hybrid/hello/nmakefile
index ea80a40..59d7111 100644
--- a/dist/examples/cxx/hybrid/hello/nmakefile
+++ b/dist/examples/cxx/hybrid/hello/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/library/makefile b/dist/examples/cxx/hybrid/library/makefile
index 512a0ba..944c724 100644
--- a/dist/examples/cxx/hybrid/library/makefile
+++ b/dist/examples/cxx/hybrid/library/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/hybrid/library/nmakefile b/dist/examples/cxx/hybrid/library/nmakefile
index e1d1a72..17f3ce0 100644
--- a/dist/examples/cxx/hybrid/library/nmakefile
+++ b/dist/examples/cxx/hybrid/library/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/hybrid/minimal/makefile b/dist/examples/cxx/hybrid/minimal/makefile
index 8224235..53a52d4 100644
--- a/dist/examples/cxx/hybrid/minimal/makefile
+++ b/dist/examples/cxx/hybrid/minimal/makefile
@@ -8,6 +8,10 @@ EXTRA_CPPFLAGS := -I$(root)/libxsde
EXTRA_XSDFLAGS := --no-stl --no-exceptions
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_IOSTREAM),n)
EXTRA_XSDFLAGS += --no-iostream
endif
diff --git a/dist/examples/cxx/hybrid/minimal/nmakefile b/dist/examples/cxx/hybrid/minimal/nmakefile
index 060be2c..30d6805 100644
--- a/dist/examples/cxx/hybrid/minimal/nmakefile
+++ b/dist/examples/cxx/hybrid/minimal/nmakefile
@@ -8,6 +8,10 @@ EXTRA_CPPFLAGS = /I$(root)\libxsde
EXTRA_XSDFLAGS = --no-stl --no-exceptions
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_IOSTREAM)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-iostream
!endif
diff --git a/dist/examples/cxx/hybrid/multiroot/makefile b/dist/examples/cxx/hybrid/multiroot/makefile
index 7329f41..f4fda3f 100644
--- a/dist/examples/cxx/hybrid/multiroot/makefile
+++ b/dist/examples/cxx/hybrid/multiroot/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/multiroot/nmakefile b/dist/examples/cxx/hybrid/multiroot/nmakefile
index d3c4e35..b550ddf 100644
--- a/dist/examples/cxx/hybrid/multiroot/nmakefile
+++ b/dist/examples/cxx/hybrid/multiroot/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/polymorphism/makefile b/dist/examples/cxx/hybrid/polymorphism/makefile
index e1f40a1..cc7148c 100644
--- a/dist/examples/cxx/hybrid/polymorphism/makefile
+++ b/dist/examples/cxx/hybrid/polymorphism/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/polymorphism/nmakefile b/dist/examples/cxx/hybrid/polymorphism/nmakefile
index bd86945..de9e356 100644
--- a/dist/examples/cxx/hybrid/polymorphism/nmakefile
+++ b/dist/examples/cxx/hybrid/polymorphism/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/polyroot/makefile b/dist/examples/cxx/hybrid/polyroot/makefile
index a422aa3..752d936 100644
--- a/dist/examples/cxx/hybrid/polyroot/makefile
+++ b/dist/examples/cxx/hybrid/polyroot/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/polyroot/nmakefile b/dist/examples/cxx/hybrid/polyroot/nmakefile
index d713db0..dbf57fb 100644
--- a/dist/examples/cxx/hybrid/polyroot/nmakefile
+++ b/dist/examples/cxx/hybrid/polyroot/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/streaming/makefile b/dist/examples/cxx/hybrid/streaming/makefile
index 6c97f8b..bb67f6a 100644
--- a/dist/examples/cxx/hybrid/streaming/makefile
+++ b/dist/examples/cxx/hybrid/streaming/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/hybrid/streaming/nmakefile b/dist/examples/cxx/hybrid/streaming/nmakefile
index 76a0c14..e9b5821 100644
--- a/dist/examples/cxx/hybrid/streaming/nmakefile
+++ b/dist/examples/cxx/hybrid/streaming/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/hybrid/wildcard/makefile b/dist/examples/cxx/hybrid/wildcard/makefile
index 0c8fd1f..3087253 100644
--- a/dist/examples/cxx/hybrid/wildcard/makefile
+++ b/dist/examples/cxx/hybrid/wildcard/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/hybrid/wildcard/nmakefile b/dist/examples/cxx/hybrid/wildcard/nmakefile
index d4d8d06..0634fa8 100644
--- a/dist/examples/cxx/hybrid/wildcard/nmakefile
+++ b/dist/examples/cxx/hybrid/wildcard/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/generated/makefile b/dist/examples/cxx/parser/generated/makefile
index bf3b512..6f77af4 100644
--- a/dist/examples/cxx/parser/generated/makefile
+++ b/dist/examples/cxx/parser/generated/makefile
@@ -14,6 +14,10 @@ EXTRA_XSDFLAGS := --generate-print-impl --generate-test-driver
#
EXTRA_XSDFLAGS += --force-overwrite
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_STL),n)
EXTRA_XSDFLAGS += --no-stl
endif
diff --git a/dist/examples/cxx/parser/generated/nmakefile b/dist/examples/cxx/parser/generated/nmakefile
index ad0900c..c801757 100644
--- a/dist/examples/cxx/parser/generated/nmakefile
+++ b/dist/examples/cxx/parser/generated/nmakefile
@@ -14,6 +14,10 @@ EXTRA_XSDFLAGS = --generate-print-impl --generate-test-driver
#
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --force-overwrite
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_STL)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
!endif
diff --git a/dist/examples/cxx/parser/hello/makefile b/dist/examples/cxx/parser/hello/makefile
index 421d69e..a136306 100644
--- a/dist/examples/cxx/parser/hello/makefile
+++ b/dist/examples/cxx/parser/hello/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/hello/nmakefile b/dist/examples/cxx/parser/hello/nmakefile
index 40d1307..60f226a 100644
--- a/dist/examples/cxx/parser/hello/nmakefile
+++ b/dist/examples/cxx/parser/hello/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/library/makefile b/dist/examples/cxx/parser/library/makefile
index 0221150..a142b56 100644
--- a/dist/examples/cxx/parser/library/makefile
+++ b/dist/examples/cxx/parser/library/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/library/nmakefile b/dist/examples/cxx/parser/library/nmakefile
index 21ffebd..fe82086 100644
--- a/dist/examples/cxx/parser/library/nmakefile
+++ b/dist/examples/cxx/parser/library/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/minimal/makefile b/dist/examples/cxx/parser/minimal/makefile
index fb0d483..aba65d9 100644
--- a/dist/examples/cxx/parser/minimal/makefile
+++ b/dist/examples/cxx/parser/minimal/makefile
@@ -8,6 +8,10 @@ EXTRA_CPPFLAGS += -I$(root)/libxsde
EXTRA_XSDFLAGS := --no-stl --no-exceptions
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_IOSTREAM),n)
EXTRA_XSDFLAGS += --no-iostream
endif
diff --git a/dist/examples/cxx/parser/minimal/nmakefile b/dist/examples/cxx/parser/minimal/nmakefile
index addf4c8..4e81aff 100644
--- a/dist/examples/cxx/parser/minimal/nmakefile
+++ b/dist/examples/cxx/parser/minimal/nmakefile
@@ -8,6 +8,10 @@ EXTRA_CPPFLAGS = /I$(root)\libxsde
EXTRA_XSDFLAGS = --no-stl --no-exceptions
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_IOSTREAM)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-iostream
!endif
diff --git a/dist/examples/cxx/parser/mixed/makefile b/dist/examples/cxx/parser/mixed/makefile
index 44d988e..b4e7426 100644
--- a/dist/examples/cxx/parser/mixed/makefile
+++ b/dist/examples/cxx/parser/mixed/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/mixed/nmakefile b/dist/examples/cxx/parser/mixed/nmakefile
index d25c2ae..bba2da4 100644
--- a/dist/examples/cxx/parser/mixed/nmakefile
+++ b/dist/examples/cxx/parser/mixed/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/multiroot/makefile b/dist/examples/cxx/parser/multiroot/makefile
index 8fdaeec..b3fb1f6 100644
--- a/dist/examples/cxx/parser/multiroot/makefile
+++ b/dist/examples/cxx/parser/multiroot/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/multiroot/nmakefile b/dist/examples/cxx/parser/multiroot/nmakefile
index 632b38b..779daa7 100644
--- a/dist/examples/cxx/parser/multiroot/nmakefile
+++ b/dist/examples/cxx/parser/multiroot/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/polymorphism/makefile b/dist/examples/cxx/parser/polymorphism/makefile
index 368401a..c970f3a 100644
--- a/dist/examples/cxx/parser/polymorphism/makefile
+++ b/dist/examples/cxx/parser/polymorphism/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/polymorphism/nmakefile b/dist/examples/cxx/parser/polymorphism/nmakefile
index a35b625..30c50cd 100644
--- a/dist/examples/cxx/parser/polymorphism/nmakefile
+++ b/dist/examples/cxx/parser/polymorphism/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/polyroot/makefile b/dist/examples/cxx/parser/polyroot/makefile
index 69e7c10..898472a 100644
--- a/dist/examples/cxx/parser/polyroot/makefile
+++ b/dist/examples/cxx/parser/polyroot/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/polyroot/nmakefile b/dist/examples/cxx/parser/polyroot/nmakefile
index f3c4ff0..220d824 100644
--- a/dist/examples/cxx/parser/polyroot/nmakefile
+++ b/dist/examples/cxx/parser/polyroot/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/parser/wildcard/makefile b/dist/examples/cxx/parser/wildcard/makefile
index 7d117bc..40591b3 100644
--- a/dist/examples/cxx/parser/wildcard/makefile
+++ b/dist/examples/cxx/parser/wildcard/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/parser/wildcard/nmakefile b/dist/examples/cxx/parser/wildcard/nmakefile
index c912a1c..99ab82f 100644
--- a/dist/examples/cxx/parser/wildcard/nmakefile
+++ b/dist/examples/cxx/parser/wildcard/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/serializer/hello/makefile b/dist/examples/cxx/serializer/hello/makefile
index a498aa4..90a752d 100644
--- a/dist/examples/cxx/serializer/hello/makefile
+++ b/dist/examples/cxx/serializer/hello/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS := -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/serializer/hello/nmakefile b/dist/examples/cxx/serializer/hello/nmakefile
index f3b3d2c..f1043a3 100644
--- a/dist/examples/cxx/serializer/hello/nmakefile
+++ b/dist/examples/cxx/serializer/hello/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/serializer/library/makefile b/dist/examples/cxx/serializer/library/makefile
index cf275b9..a6166a3 100644
--- a/dist/examples/cxx/serializer/library/makefile
+++ b/dist/examples/cxx/serializer/library/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/serializer/library/nmakefile b/dist/examples/cxx/serializer/library/nmakefile
index 9399f5d..71a21f0 100644
--- a/dist/examples/cxx/serializer/library/nmakefile
+++ b/dist/examples/cxx/serializer/library/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/serializer/minimal/makefile b/dist/examples/cxx/serializer/minimal/makefile
index 4c8c23c..5c17e24 100644
--- a/dist/examples/cxx/serializer/minimal/makefile
+++ b/dist/examples/cxx/serializer/minimal/makefile
@@ -8,6 +8,10 @@ EXTRA_CPPFLAGS += -I$(root)/libxsde
EXTRA_XSDFLAGS := --no-stl --no-exceptions
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_IOSTREAM),n)
EXTRA_XSDFLAGS += --no-iostream
endif
diff --git a/dist/examples/cxx/serializer/minimal/nmakefile b/dist/examples/cxx/serializer/minimal/nmakefile
index 7b1def3..0184770 100644
--- a/dist/examples/cxx/serializer/minimal/nmakefile
+++ b/dist/examples/cxx/serializer/minimal/nmakefile
@@ -8,6 +8,10 @@ EXTRA_CPPFLAGS = /I$(root)\libxsde
EXTRA_XSDFLAGS = --no-stl --no-exceptions
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_IOSTREAM)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-iostream
!endif
diff --git a/dist/examples/cxx/serializer/polymorphism/makefile b/dist/examples/cxx/serializer/polymorphism/makefile
index a602422..6f5b4c8 100644
--- a/dist/examples/cxx/serializer/polymorphism/makefile
+++ b/dist/examples/cxx/serializer/polymorphism/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/serializer/polymorphism/nmakefile b/dist/examples/cxx/serializer/polymorphism/nmakefile
index ad10eea..75e9d7c 100644
--- a/dist/examples/cxx/serializer/polymorphism/nmakefile
+++ b/dist/examples/cxx/serializer/polymorphism/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/serializer/polyroot/makefile b/dist/examples/cxx/serializer/polyroot/makefile
index a602422..6f5b4c8 100644
--- a/dist/examples/cxx/serializer/polyroot/makefile
+++ b/dist/examples/cxx/serializer/polyroot/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/serializer/polyroot/nmakefile b/dist/examples/cxx/serializer/polyroot/nmakefile
index ad10eea..75e9d7c 100644
--- a/dist/examples/cxx/serializer/polyroot/nmakefile
+++ b/dist/examples/cxx/serializer/polyroot/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/examples/cxx/serializer/wildcard/makefile b/dist/examples/cxx/serializer/wildcard/makefile
index 9c99a98..742d8ff 100644
--- a/dist/examples/cxx/serializer/wildcard/makefile
+++ b/dist/examples/cxx/serializer/wildcard/makefile
@@ -6,6 +6,10 @@ include $(root)/build/cxx/rules.make
#
EXTRA_CPPFLAGS += -I$(root)/libxsde
+ifeq ($(XSDE_ENCODING),iso8859-1)
+EXTRA_XSDFLAGS += --char-encoding iso8859-1
+endif
+
ifeq ($(XSDE_LONGLONG),n)
EXTRA_XSDFLAGS += --no-long-long
endif
diff --git a/dist/examples/cxx/serializer/wildcard/nmakefile b/dist/examples/cxx/serializer/wildcard/nmakefile
index a6c0feb..9ca6d8c 100644
--- a/dist/examples/cxx/serializer/wildcard/nmakefile
+++ b/dist/examples/cxx/serializer/wildcard/nmakefile
@@ -6,6 +6,10 @@ root = ..\..\..\..
#
EXTRA_CPPFLAGS = /I$(root)\libxsde
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --char-encoding iso8859-1
+!endif
+
!if "$(XSDE_LONGLONG)" == "n"
EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
!endif
diff --git a/dist/libxsde/xsde/makefile b/dist/libxsde/xsde/makefile
index 9abff7a..60c5ba3 100644
--- a/dist/libxsde/xsde/makefile
+++ b/dist/libxsde/xsde/makefile
@@ -11,6 +11,10 @@ src += c/genx/genx.c c/genx/char-props.c
src += cxx/string.cxx cxx/ro-string.cxx cxx/stack.cxx
+ifeq ($(XSDE_ENCODING),iso8859-1)
+src += cxx/iso8859-1.cxx
+endif
+
ifeq ($(XSDE_STL),n)
src += cxx/strdupx.cxx
endif
@@ -506,6 +510,20 @@ endif
ifeq ($(XSDE_BYTEORDER),b)
@echo $(h)define XSDE_BYTEORDER 4321 >>$@
endif
+ifeq ($(XSDE_ENCODING),utf8)
+ @echo $(h)define XSDE_ENCODING_UTF8 >>$@
+else
+ifeq ($(XSDE_ENCODING),)
+ @echo $(h)define XSDE_ENCODING_UTF8 >>$@
+else
+ @echo $(h)undef XSDE_ENCODING_UTF8 >>$@
+endif
+endif
+ifeq ($(XSDE_ENCODING),iso8859-1)
+ @echo $(h)define XSDE_ENCODING_ISO8859_1 >>$@
+else
+ @echo $(h)undef XSDE_ENCODING_ISO8859_1 >>$@
+endif
ifeq ($(XSDE_STL),y)
@echo $(h)define XSDE_STL >>$@
endif
diff --git a/dist/libxsde/xsde/nmakefile b/dist/libxsde/xsde/nmakefile
index dd806f7..90fc489 100644
--- a/dist/libxsde/xsde/nmakefile
+++ b/dist/libxsde/xsde/nmakefile
@@ -13,6 +13,10 @@ src = $(src) c\genx\genx.c c\genx\char-props.c
src = $(src) cxx\string.cxx cxx\ro-string.cxx cxx\stack.cxx
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+src = $(src) cxx\iso8859-1.cxx
+!endif
+
!if "$(XSDE_STL)" == "n"
src = $(src) cxx\strdupx.cxx
!endif
@@ -501,6 +505,20 @@ config.h:
!if "$(XSDE_BYTEORDER)" == "b"
@echo #define XSDE_BYTEORDER 4321 >>$@
!endif
+!if "$(XSDE_ENCODING)" == "utf8"
+ @echo #define XSDE_ENCODING_UTF8 >>$@
+!else
+!if "$(XSDE_ENCODING)" == ""
+ @echo #define XSDE_ENCODING_UTF8 >>$@
+!else
+ @echo #undef XSDE_ENCODING_UTF8 >>$@
+!endif
+!endif
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+ @echo #define XSDE_ENCODING_ISO8859_1 >>$@
+!else
+ @echo #undef XSDE_ENCODING_ISO8859_1 >>$@
+!endif
!if "$(XSDE_STL)" == "y"
@echo #define XSDE_STL >>$@
!endif
diff --git a/dist/tests/cxx/hybrid/makefile b/dist/tests/cxx/hybrid/makefile
index 3cd2d7d..ddcf464 100644
--- a/dist/tests/cxx/hybrid/makefile
+++ b/dist/tests/cxx/hybrid/makefile
@@ -17,6 +17,10 @@ endif
ifeq ($(XSDE_IOSTREAM),y)
dirs += built-in default enumeration list test-template union
+ifeq ($(XSDE_ENCODING),iso8859-1)
+dirs += iso8859-1
+endif
+
ifeq ($(XSDE_CDR),y)
dirs += binary/cdr
endif
diff --git a/dist/tests/cxx/hybrid/nmakefile b/dist/tests/cxx/hybrid/nmakefile
index 9052637..1127649 100644
--- a/dist/tests/cxx/hybrid/nmakefile
+++ b/dist/tests/cxx/hybrid/nmakefile
@@ -17,6 +17,10 @@ dirs = $(dirs) iterator
!if "$(XSDE_IOSTREAM)" == "y"
dirs = $(dirs) built-in default enumeration list test-template union
+!if "$(XSDE_ENCODING)" == "iso8859-1"
+dirs = $(dirs) iso8859-1
+!endif
+
!if "$(XSDE_CDR)" == "y"
dirs = $(dirs) binary/cdr
!endif
diff --git a/documentation/cxx/hybrid/guide/index.xhtml b/documentation/cxx/hybrid/guide/index.xhtml
index 8c46932..dead3dc 100644
--- a/documentation/cxx/hybrid/guide/index.xhtml
+++ b/documentation/cxx/hybrid/guide/index.xhtml
@@ -1265,15 +1265,34 @@ main (int argc, char* argv[])
Compiler Command Line Manual</a>.
</p>
- <p>While the XML documents can use various encodings, the Embedded
- C++/Hybrid mapping always delivers character data to the application
- in the UTF-8 encoding. The underlying XML parser used by the mapping
- includes built-in support for XML documents encoded in UTF-8, UTF-16,
- ISO-8859-1, and US-ASCII. Other encodings can be supported by providing
- application-specific decoder functions. C++/Hybrid also expects character
- data supplied by the application to be in the UTF-8 encoding. The
- underlying XML serializer used by the mapping produces the resulting
- XML in the UTF-8 encoding as well.</p>
+ <p>While the XML documents can use various encodings, the C++/Hybrid
+ object model always stores character data in the same encoding,
+ called application encoding. The application encoding can either be
+ UTF-8 (default) or ISO-8859-1. To select a particular encoding, configure
+ the XSD/e runtime library accordingly and pass the <code>--char-encoding</code>
+ option to the XSD/e compiler when translating your schemas.</p>
+
+ <p>When using ISO-8859-1 as the application encoding, XML documents
+ being parsed may contain characters with Unicode values greater
+ than 0xFF which are unrepresentable in the ISO-8859-1 encoding.
+ By default, in such situations parsing will terminate with
+ an error. However, you can suppress the error by providing a
+ replacement character that should be used instead of
+ unrepresentable characters, for example:</p>
+
+ <pre class="c++">
+xml_schema::iso8859_1::unrep_char ('?');
+ </pre>
+
+ <p>To revert to the default behavior, set the replacement character
+ to <code>'\0'</code>.</p>
+
+ <p>The underlying XML parser used by the mapping includes built-in
+ support for XML documents encoded in UTF-8, UTF-16, ISO-8859-1,
+ and US-ASCII. Other encodings can be supported by providing
+ application-specific decoder functions. The underlying XML
+ serializer used by C++/Hybrid produces the resulting
+ XML documents in the UTF-8 encoding.</p>
<h2><a name="3.1">3.1 Standard Template Library</a></h2>
diff --git a/documentation/cxx/parser/guide/index.xhtml b/documentation/cxx/parser/guide/index.xhtml
index 305c420..6a019c5 100644
--- a/documentation/cxx/parser/guide/index.xhtml
+++ b/documentation/cxx/parser/guide/index.xhtml
@@ -1991,8 +1991,27 @@ age: 28
<p>While the XML documents can use various encodings, the Embedded
C++/Parser mapping always delivers character data to the application
- in the UTF-8 encoding. The underlying XML parser used by the
- Embedded C++/Parser mapping includes built-in support for XML
+ in the same encoding. The application encoding can either be UTF-8
+ (default) or ISO-8859-1. To select a particular encoding, configure
+ the XSD/e runtime library accordingly and pass the <code>--char-encoding</code>
+ option to the XSD/e compiler when translating your schemas.</p>
+
+ <p>When using ISO-8859-1 as the application encoding, XML documents
+ being parsed may contain characters with Unicode values greater
+ than 0xFF which are unrepresentable in the ISO-8859-1 encoding.
+ By default, in such situations parsing will terminate with
+ an error. However, you can suppress the error by providing a
+ replacement character that should be used instead of
+ unrepresentable characters, for example:</p>
+
+ <pre class="c++">
+xml_schema::iso8859_1::unrep_char ('?');
+ </pre>
+
+ <p>To revert to the default behavior, set the replacement character
+ to <code>'\0'</code>.</p>
+
+ <p>The Embedded C++/Parser mapping includes built-in support for XML
documents encoded in UTF-8, UTF-16, ISO-8859-1, and US-ASCII.
Other encodings can be supported by providing application-specific
decoder functions.</p>
diff --git a/documentation/cxx/serializer/guide/index.xhtml b/documentation/cxx/serializer/guide/index.xhtml
index 5abb31f..34ef798 100644
--- a/documentation/cxx/serializer/guide/index.xhtml
+++ b/documentation/cxx/serializer/guide/index.xhtml
@@ -2609,10 +2609,13 @@ private:
</p>
<p>The Embedded C++/Serializer mapping always expects character data
- supplied by the application to be in the UTF-8 encoding. The
- underlying XML serializer used by the Embedded C++/Serializer
- mapping produces the resulting XML in the UTF-8 encoding as
- well.</p>
+ supplied by the application to be in the same encoding. The
+ application encoding can either be UTF-8 (default) or ISO-8859-1.
+ To select a particular encoding, configure the XSD/e runtime library
+ accordingly and pass the <code>--char-encoding</code> option to the
+ XSD/e compiler when translating your schemas. The underlying XML
+ serializer used by the Embedded C++/Serializer mapping produces
+ the resulting XML documents in the UTF-8 encoding.</p>
<h2><a name="6.1">6.1 Standard Template Library</a></h2>
diff --git a/documentation/xsde.1 b/documentation/xsde.1
index 0c0dc72..afafa8c 100644
--- a/documentation/xsde.1
+++ b/documentation/xsde.1
@@ -175,6 +175,19 @@ Write generated files to
.I dir
instead of the current directory.
+.IP "\fB\--char-encoding \fIenc\fR"
+Specify the application character encoding. Valid values are
+.B utf8
+(default) and
+.BR iso8859-1 .
+Note that this encoding is not the same as the XML document encoding
+that is being parsed or serialized. Rather, it is the encoding that
+is used inside the application. When an XML document is parsed, the
+character data is automatically converted to the application encoding.
+Similarly, when an XML document is serialized, the data in the
+application encoding is automatically converted to the resulting
+document encoding.
+
.IP "\fB\--no-stl\fR"
Generate code that does not use the Standard Template Library (STL).
diff --git a/documentation/xsde.xhtml b/documentation/xsde.xhtml
index 9328e99..31c2f03 100644
--- a/documentation/xsde.xhtml
+++ b/documentation/xsde.xhtml
@@ -166,6 +166,17 @@
<dd>Write generated files to <code><i>dir</i></code> instead of
the current directory.</dd>
+ <dt><code><b>--char-encoding</b> <i>enc</i></code></dt>
+ <dd>Specify the application character encoding. Valid values are
+ <code><b>utf8</b></code> (default) and <code><b>iso8859-1</b></code>.
+ Note that this encoding is not the same as the XML document encoding
+ that is being parsed or serialized. Rather, it is the encoding that
+ is used inside the application. When an XML document is parsed, the
+ character data is automatically converted to the application encoding.
+ Similarly, when an XML document is serialized, the data in the
+ application encoding is automatically converted to the resulting
+ document encoding.</dd>
+
<dt><code><b>--no-stl</b></code></dt>
<dd>Generate code that does not use the Standard Template Library
(STL).</dd>
diff --git a/libxsde/xsde/cxx/iso8859-1.cxx b/libxsde/xsde/cxx/iso8859-1.cxx
new file mode 100644
index 0000000..b52a284
--- /dev/null
+++ b/libxsde/xsde/cxx/iso8859-1.cxx
@@ -0,0 +1,170 @@
+// file : xsde/cxx/iso8859-1.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/iso8859-1.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ char iso8859_1::unrep_char_ = '\0';
+
+ bool iso8859_1::
+ to (const char* s, char* r)
+ {
+ for (; *s != 0; ++s)
+ {
+ unsigned char c (*s);
+
+ if (c < 0x80)
+ {
+ // Fast path.
+ //
+ *r++ = c;
+ continue;
+ }
+ else if ((c >> 5) == 0x06)
+ {
+ // UTF-8: 110yyyyy 10zzzzzz
+ // Unicode: 00000yyy yyzzzzzz
+ //
+ unsigned int u = (c & 0x1F) << 6;
+ c = *++s;
+ u |= c & 0x3F;
+
+ if (u < 0x100)
+ {
+ *r++ = static_cast<char> (u);
+ continue;
+ }
+ }
+ else if ((c >> 4) == 0x0E)
+ {
+ // UTF-8: 1110xxxx 10yyyyyy 10zzzzzz
+ // Unicode: xxxxyyyy yyzzzzzz
+ //
+ s += 2;
+ }
+ else if ((c >> 3) == 0x1E)
+ {
+ // UTF-8: 000wwwxx xxxxyyyy yyzzzzzz
+ // Unicode: 11110www 10xxxxxx 10yyyyyy 10zzzzzz
+ //
+ s += 3;
+ }
+
+ if (unrep_char_ != '\0')
+ *r++ = unrep_char_;
+ else
+ return false;
+ }
+
+ *r = '\0';
+
+ return true;
+ }
+
+ bool iso8859_1::
+ to (const char* s, size_t n, char* r)
+ {
+ const char* end = s + n;
+
+ for (; s != end; ++s)
+ {
+ unsigned char c (*s);
+
+ if (c < 0x80)
+ {
+ // Fast path.
+ //
+ *r++ = c;
+ continue;
+ }
+ else if ((c >> 5) == 0x06)
+ {
+ // UTF-8: 110yyyyy 10zzzzzz
+ // Unicode: 00000yyy yyzzzzzz
+ //
+ unsigned int u = (c & 0x1F) << 6;
+ c = *++s;
+ u |= c & 0x3F;
+
+ if (u < 0x100)
+ {
+ *r++ = static_cast<char> (u);
+ continue;
+ }
+ }
+ else if ((c >> 4) == 0x0E)
+ {
+ // UTF-8: 1110xxxx 10yyyyyy 10zzzzzz
+ // Unicode: xxxxyyyy yyzzzzzz
+ //
+ s += 2;
+ }
+ else if ((c >> 3) == 0x1E)
+ {
+ // UTF-8: 000wwwxx xxxxyyyy yyzzzzzz
+ // Unicode: 11110www 10xxxxxx 10yyyyyy 10zzzzzz
+ //
+ s += 3;
+ }
+
+ if (unrep_char_ != '\0')
+ *r++ = unrep_char_;
+ else
+ return false;
+ }
+
+ *r = '\0';
+
+ return true;
+ }
+
+ void iso8859_1::
+ from (const char* s, char* r)
+ {
+ for (; *s != 0; ++s)
+ {
+ unsigned char c (*s);
+
+ if (c < 0x80)
+ *r++ = c;
+ else
+ {
+ // 2-byte sequence.
+ //
+ *r++ = (c >> 6) | 0xC0;
+ *r++ = (c | 0x80) & 0xBF;
+ }
+ }
+
+ *r = '\0';
+ }
+
+ void iso8859_1::
+ from (const char* s, size_t n, char* r)
+ {
+ const char* end = s + n;
+
+ for (; s != end; ++s)
+ {
+ unsigned char c (*s);
+
+ if (c < 0x80)
+ *r++ = c;
+ else
+ {
+ // 2-byte sequence.
+ //
+ *r++ = (c >> 6) | 0xC0;
+ *r++ = (c | 0x80) & 0xBF;
+ }
+ }
+
+ *r = '\0';
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/iso8859-1.hxx b/libxsde/xsde/cxx/iso8859-1.hxx
new file mode 100644
index 0000000..5809886
--- /dev/null
+++ b/libxsde/xsde/cxx/iso8859-1.hxx
@@ -0,0 +1,85 @@
+// file : xsde/cxx/iso8859-1.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_ISO8859_1_HXX
+#define XSDE_CXX_ISO8859_1_HXX
+
+#include <stddef.h> // size_t
+
+#include <xsde/cxx/config.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ class iso8859_1
+ {
+ public:
+ // Get/set a replacement for unrepresentable characters. If set to
+ // 0 (the default value), the conversion fails if such a character
+ // is encountered.
+ //
+ static char
+ unrep_char ()
+ {
+ return unrep_char_;
+ }
+
+ static void
+ unrep_char (char c)
+ {
+ unrep_char_ = c;
+ }
+
+ public:
+ // Test whether a UTF-8 string is an ASCII string. If these
+ // functions return false, the iso_size argument contains
+ // the size of the buffer needed to convert this string to
+ // ISO-8859-1.
+ //
+ static bool
+ ascii_utf (const char* utf_str, size_t& iso_size);
+
+ static bool
+ ascii_utf (const char* utf_str, size_t utf_size, size_t& iso_size);
+
+ // Test whether an ISO-8859-1 string is an ASCII string. If
+ // these functions return false, the utf_size argument contains
+ // the size of the buffer needed to convert this string to UTF-8.
+ //
+ static bool
+ ascii_iso (const char* iso_str, size_t& utf_size);
+
+ static bool
+ ascii_iso (const char* iso_str, size_t iso_size, size_t& utf_size);
+
+ // Convert from UTF-8 to ISO-8859-1. Return false if an
+ // unrepresentable character was encountered and no replacement
+ // was specified.
+ //
+ //
+ static bool
+ to (const char* utf_str, char* iso_str);
+
+ static bool
+ to (const char* utf_str, size_t utf_size, char* iso_str);
+
+ // Convert from ISO-8859-1 to UTF-8.
+ //
+ static void
+ from (const char* iso_str, char* utf_str);
+
+ static void
+ from (const char* iso_str, size_t iso_size, char* utf_str);
+
+ private:
+ static char unrep_char_;
+ };
+ }
+}
+
+#include <xsde/cxx/iso8859-1.ixx>
+
+#endif // XSDE_CXX_ISO8859_1_HXX
diff --git a/libxsde/xsde/cxx/iso8859-1.ixx b/libxsde/xsde/cxx/iso8859-1.ixx
new file mode 100644
index 0000000..716be53
--- /dev/null
+++ b/libxsde/xsde/cxx/iso8859-1.ixx
@@ -0,0 +1,128 @@
+// file : xsde/cxx/iso8859-1.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ inline bool iso8859_1::
+ ascii_utf (const char* s, size_t& rn)
+ {
+ // NULL string is an ASCII string.
+ //
+ if (s == 0)
+ return true;
+
+ bool r = true;
+ size_t l = 0;
+
+ for (; *s != 0; ++s, ++l)
+ {
+ unsigned char c (*s);
+
+ if (c > 0x7F)
+ {
+ if ((c >> 5) == 0x06)
+ ++s;
+ else if ((c >> 4) == 0x0E)
+ s += 2;
+ else if ((c >> 3) == 0x1E)
+ s += 3;
+
+ r = false;
+ }
+ }
+
+ rn = l + 1;
+ return r;
+ }
+
+ inline bool iso8859_1::
+ ascii_utf (const char* s, size_t n, size_t& rn)
+ {
+ // NULL string is an ASCII string.
+ //
+ if (s == 0)
+ return true;
+
+ bool r = true;
+ size_t l = 0;
+ const char* end = s + n;
+
+ for (; s != end; ++s, ++l)
+ {
+ unsigned char c (*s);
+
+ if (c > 0x7F)
+ {
+ if ((c >> 5) == 0x06)
+ ++s;
+ else if ((c >> 4) == 0x0E)
+ s += 2;
+ else if ((c >> 3) == 0x1E)
+ s += 3;
+
+ r = false;
+ }
+ }
+
+ rn = l + 1;
+ return r;
+ }
+
+ inline bool iso8859_1::
+ ascii_iso (const char* s, size_t& rn)
+ {
+ // NULL string is an ASCII string.
+ //
+ if (s == 0)
+ return true;
+
+ bool r = true;
+ size_t l = 0;
+
+ for (; *s != 0; ++s, ++l)
+ {
+ unsigned char c (*s);
+
+ if (c > 0x7F)
+ {
+ ++l; // 2-byte surrogate.
+ r = false;
+ }
+ }
+
+ rn = l + 1;
+ return r;
+ }
+
+ inline bool iso8859_1::
+ ascii_iso (const char* s, size_t n, size_t& rn)
+ {
+ // NULL string is an ASCII string.
+ //
+ if (s == 0)
+ return true;
+
+ bool r = true;
+ size_t l = 0;
+ const char* end = s + n;
+
+ for (; s != end; ++s, ++l)
+ {
+ unsigned char c (*s);
+
+ if (c > 0x7F)
+ {
+ ++l; // 2-byte surrogate.
+ r = false;
+ }
+ }
+
+ rn = l + 1;
+ return r;
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/parser/expat/document.cxx b/libxsde/xsde/cxx/parser/expat/document.cxx
index 4bb3ec0..61cc1d0 100644
--- a/libxsde/xsde/cxx/parser/expat/document.cxx
+++ b/libxsde/xsde/cxx/parser/expat/document.cxx
@@ -17,6 +17,10 @@
# include <fstream>
#endif
+#ifdef XSDE_ENCODING_ISO8859_1
+# include <xsde/cxx/iso8859-1.hxx>
+#endif
+
#ifdef XSDE_EXCEPTIONS
# include <xsde/cxx/parser/exceptions.hxx>
#endif
@@ -58,6 +62,9 @@ namespace xsde
#endif
: first_ (true), xml_parser_ (0), context_ (0), parser_ (&p)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
#ifdef XSDE_POLYMORPHIC
polymorphic_ = poly;
#endif
@@ -77,6 +84,9 @@ namespace xsde
#endif
: first_ (true), xml_parser_ (0), context_ (0), parser_ (&p)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
#ifdef XSDE_POLYMORPHIC
polymorphic_ = poly;
#endif
@@ -93,6 +103,9 @@ namespace xsde
#endif
: first_ (true), xml_parser_ (0), context_ (0), parser_ (&p)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
#ifdef XSDE_POLYMORPHIC
polymorphic_ = poly;
#endif
@@ -110,6 +123,9 @@ namespace xsde
#endif
: first_ (true), xml_parser_ (0), context_ (0), parser_ (&p)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
#ifdef XSDE_POLYMORPHIC
polymorphic_ = poly;
#endif
@@ -120,6 +136,9 @@ namespace xsde
document_pimpl ()
: first_ (true), xml_parser_ (0), context_ (0), parser_ (0)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
#ifdef XSDE_POLYMORPHIC
polymorphic_ = false;
#endif
@@ -131,6 +150,9 @@ namespace xsde
: first_ (true), xml_parser_ (0), context_ (0), parser_ (0),
polymorphic_ (true)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
init_root_name (0, n);
}
@@ -139,6 +161,9 @@ namespace xsde
: first_ (true), xml_parser_ (0), context_ (0), parser_ (0),
polymorphic_ (true)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
init_root_name (ns, n);
}
@@ -148,6 +173,9 @@ namespace xsde
: first_ (true), xml_parser_ (0), context_ (0), parser_ (0),
polymorphic_ (true)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
init_root_name (0, n.c_str ());
}
@@ -156,6 +184,9 @@ namespace xsde
: first_ (true), xml_parser_ (0), context_ (0), parser_ (0),
polymorphic_ (true)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
init_root_name (ns.c_str (), n.c_str ());
}
#endif // XSDE_STL
@@ -208,6 +239,10 @@ namespace xsde
#ifndef XSDE_EXCEPTIONS
error_ = error ();
#endif
+
+#ifdef XSDE_ENCODING_ISO8859_1
+ xml_error_ = 0;
+#endif
first_ = true;
if (parser_)
@@ -405,6 +440,18 @@ namespace xsde
//
if (e == XML_ERROR_ABORTED)
{
+#ifdef XSDE_ENCODING_ISO8859_1
+ if (xml_error_ != 0)
+ {
+#ifdef XSDE_EXCEPTIONS
+ throw xml (xml_error_, l, c);
+#else
+ error_ = error (xml_error_, l, c);
+ return;
+#endif
+ }
+#endif
+
// Got to be either a system, schema, or application
// level error.
//
@@ -584,11 +631,35 @@ namespace xsde
return;
}
+ // Convert to application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* ans_name = ns_name;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* ans_name;
+ size_t an;
+ string buf;
+
+ if (iso8859_1::ascii_utf (ns_name, an))
+ ans_name = ns_name;
+ else
+ {
+ ans_name = conv_name (ns_name, an, buf);
+
+ if (ans_name == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+
+#endif // XSDE_ENCODING_*
+
const char* ns_p;
const char* name_p;
size_t ns_s, name_s;
- bits::split_name (ns_name, ns_p, ns_s, name_p, name_s);
+ bits::split_name (ans_name, ns_p, ns_s, name_p, name_s);
parser_state& cur = context_.current_;
@@ -602,7 +673,10 @@ namespace xsde
if (polymorphic_)
{
- // Search for the xsi:type attribute.
+ // Search for the xsi:type attribute. The name and
+ // namespace of the attribute that we are looking for
+ // are ASCII strings so we don't need to convert it to
+ // the application encoding.
//
const XML_Char** p = atts; // VC8 can't handle p (atts)
for (; *p != 0; p += 2)
@@ -622,9 +696,34 @@ namespace xsde
// @@ Need proper QName validation.
//
+
+ // Convert the type name to the application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* av = *(p + 1);
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* av;
+ size_t an;
+ string buf;
+
+ if (iso8859_1::ascii_utf (*(p + 1), an))
+ av = *(p + 1);
+ else
+ {
+ av = conv_data (*(p + 1), an, buf);
+
+ if (av == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+
+#endif // XSDE_ENCODING_*
+
// Get the qualified type name and try to resolve it.
//
- ro_string qn (*(p + 1));
+ ro_string qn (av);
ro_string tp, tn;
size_t pos = qn.find (':');
@@ -834,10 +933,53 @@ namespace xsde
{
for (; *atts != 0; atts += 2)
{
- bits::split_name (*atts, ns_p, ns_s, name_p, name_s);
+ // Convert the type name to the application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* aname = *atts;
+ const char* avalue = *(atts + 1);
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* aname;
+ const char* avalue;
+ size_t an;
+ string nbuf, vbuf;
+
+ // Name.
+ //
+ if (iso8859_1::ascii_utf (*atts, an))
+ aname = *atts;
+ else
+ {
+ aname = conv_name (*atts, an, nbuf);
+
+ if (aname == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+
+ // Value.
+ //
+ if (iso8859_1::ascii_utf (*(atts + 1), an))
+ avalue = *(atts + 1);
+ else
+ {
+ avalue = conv_data (*(atts + 1), an, vbuf);
+
+ if (avalue == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+
+#endif // XSDE_ENCODING_*
+
+ bits::split_name (aname, ns_p, ns_s, name_p, name_s);
const ro_string ns (ns_p, ns_s), name (name_p, name_s);
- const ro_string value (*(atts + 1));
+ const ro_string value (avalue);
if (!cur.any_)
cur.parser_->_attribute (ns, name, value);
@@ -867,19 +1009,41 @@ namespace xsde
return;
}
+ // Convert to application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* ans_name = ns_name;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* ans_name;
+ size_t an;
+ string buf;
+
+ if (iso8859_1::ascii_utf (ns_name, an))
+ ans_name = ns_name;
+ else
+ {
+ ans_name = conv_name (ns_name, an, buf);
+
+ if (ans_name == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+
+#endif // XSDE_ENCODING_*
+
const char* ns_p;
const char* name_p;
size_t ns_s, name_s;
- bits::split_name (ns_name, ns_p, ns_s, name_p, name_s);
+ bits::split_name (ans_name, ns_p, ns_s, name_p, name_s);
const ro_string ns (ns_p, ns_s);
const ro_string name (name_p, name_s);
parser_state& cur = context_.current_;
- // @@ Error propagation.
- //
if (cur.depth_ == 0)
{
// The "normal" case: call _post to pop the parser and then
@@ -980,7 +1144,37 @@ namespace xsde
if (n != 0 && (cur.depth_ == 0 || cur.any_))
{
- const ro_string str (s, n);
+ // Convert to application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* as = s;
+ size_t an = n;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* as;
+ size_t an;
+ string buf;
+
+ if (iso8859_1::ascii_utf (s, n, an))
+ {
+ as = s;
+ an = n;
+ }
+ else
+ {
+ as = conv_data (s, n, an, buf);
+
+ if (as == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+
+ --an; // Discount trailing zero.
+ }
+
+#endif // XSDE_ENCODING_*
+
+ const ro_string str (as, an);
if (!cur.any_)
cur.parser_->_characters (str);
@@ -1003,22 +1197,66 @@ namespace xsde
//
if (polymorphic_)
{
-#if defined (XSDE_STL)
- prefixes_.push_back (p ? p : "");
- prefix_namespaces_.push_back (ns ? ns : "");
-#else
-#if defined (XSDE_EXCEPTIONS)
- prefixes_.push_back_copy (p ? p : "");
- prefix_namespaces_.push_back_copy (ns ? ns : "");
+ // Convert the type name to the application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* ap = p;
+ const char* ans = ns;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* ap;
+ const char* ans;
+ size_t an;
+ string pbuf, nsbuf;
+
+ // Prefix.
+ //
+ if (p == 0)
+ ap = 0;
+ else if (iso8859_1::ascii_utf (p, an))
+ ap = p;
+ else
+ {
+ ap = conv_name (p, an, pbuf);
+
+ if (ap == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+
+ // Namespace.
+ //
+ if (ns == 0)
+ ans = 0;
+ else if (iso8859_1::ascii_utf (ns, an))
+ ans = ns;
+ else
+ {
+ ans = conv_data (ns, an, nsbuf);
+
+ if (ans == 0)
+ {
+ XML_StopParser (xml_parser_, false);
+ return;
+ }
+ }
+#endif // XSDE_ENCODING_*
+
+#ifdef XSDE_STL
+ prefixes_.push_back (ap ? ap : "");
+ prefix_namespaces_.push_back (ans ? ans : "");
+#elif defined (XSDE_EXCEPTIONS)
+ prefixes_.push_back_copy (ap ? ap : "");
+ prefix_namespaces_.push_back_copy (ans ? ans : "");
#else
- if (prefixes_.push_back_copy (p ? p : "" ) ||
- prefix_namespaces_.push_back_copy (ns ? ns : ""))
+ if (prefixes_.push_back_copy (ap ? ap : "" ) ||
+ prefix_namespaces_.push_back_copy (ans ? ans : ""))
{
context_.sys_error (sys_error::no_memory);
XML_StopParser (xml_parser_, false);
}
#endif
-#endif
}
}
@@ -1038,6 +1276,105 @@ namespace xsde
}
}
#endif // XSDE_POLYMORPHIC
+
+ //
+ // Support for ISO-8859-1 conversion.
+ //
+
+#ifdef XSDE_ENCODING_ISO8859_1
+ const char* document_pimpl::
+ conv_data (const XML_Char* utf_s, size_t iso_n, string& var)
+ {
+ char* buf;
+
+ if (iso_n <= sizeof (data_buf_))
+ buf = data_buf_;
+ else
+ {
+ buf = new char[iso_n];
+
+#ifndef XSDE_EXCEPTIONS
+ if (buf == 0)
+ {
+ context_.sys_error (sys_error::no_memory);
+ return 0;
+ }
+#endif
+ var.attach (buf, iso_n - 1);
+ }
+
+ if (!iso8859_1::to (utf_s, buf))
+ {
+ xml_error_ = XML_ERROR_UNREPRESENTABLE;
+ return 0;
+ }
+
+ return buf;
+ }
+
+ const char* document_pimpl::
+ conv_data (const XML_Char* utf_s,
+ size_t utf_n,
+ size_t iso_n,
+ string& var)
+ {
+ char* buf;
+
+ if (iso_n <= sizeof (data_buf_))
+ buf = data_buf_;
+ else
+ {
+ buf = new char[iso_n];
+
+#ifndef XSDE_EXCEPTIONS
+ if (buf == 0)
+ {
+ context_.sys_error (sys_error::no_memory);
+ return 0;
+ }
+#endif
+ var.attach (buf, iso_n - 1);
+ }
+
+ if (!iso8859_1::to (utf_s, utf_n, buf))
+ {
+ xml_error_ = XML_ERROR_UNREPRESENTABLE;
+ return 0;
+ }
+
+ return buf;
+ }
+
+ const char* document_pimpl::
+ conv_name (const XML_Char* utf_s, size_t iso_n, string& var)
+ {
+ char* buf;
+
+ if (iso_n <= sizeof (name_buf_))
+ buf = name_buf_;
+ else
+ {
+ buf = new char[iso_n];
+
+#ifndef XSDE_EXCEPTIONS
+ if (buf == 0)
+ {
+ context_.sys_error (sys_error::no_memory);
+ return 0;
+ }
+#endif
+ var.attach (buf, iso_n - 1);
+ }
+
+ if (!iso8859_1::to (utf_s, buf))
+ {
+ xml_error_ = XML_ERROR_UNREPRESENTABLE;
+ return 0;
+ }
+
+ return buf;
+ }
+#endif // XSDE_ENCODING_ISO8859_1
}
}
}
diff --git a/libxsde/xsde/cxx/parser/expat/document.hxx b/libxsde/xsde/cxx/parser/expat/document.hxx
index afa7625..df3bf21 100644
--- a/libxsde/xsde/cxx/parser/expat/document.hxx
+++ b/libxsde/xsde/cxx/parser/expat/document.hxx
@@ -323,6 +323,27 @@ namespace xsde
error error_;
#endif
+ // Support for ISO-8859-1 conversion.
+ //
+#ifdef XSDE_ENCODING_ISO8859_1
+ protected:
+ const char*
+ conv_data (const XML_Char* utf_s, size_t iso_n, string& var);
+
+ const char*
+ conv_data (const XML_Char* utf_s,
+ size_t utf_n,
+ size_t iso_n,
+ string& var);
+
+ const char*
+ conv_name (const XML_Char* utf_s, size_t iso_n, string& var);
+
+ xml_error xml_error_;
+
+ char data_buf_[256];
+ char name_buf_[128];
+#endif
private:
void
init_root_name (const char* ns, const char* name);
diff --git a/libxsde/xsde/cxx/parser/expat/document.ixx b/libxsde/xsde/cxx/parser/expat/document.ixx
index 72451ee..16d6ef7 100644
--- a/libxsde/xsde/cxx/parser/expat/document.ixx
+++ b/libxsde/xsde/cxx/parser/expat/document.ixx
@@ -50,4 +50,3 @@ namespace xsde
}
}
}
-
diff --git a/libxsde/xsde/cxx/parser/expat/xml-error.cxx b/libxsde/xsde/cxx/parser/expat/xml-error.cxx
index cb7b904..b5f15a4 100644
--- a/libxsde/xsde/cxx/parser/expat/xml-error.cxx
+++ b/libxsde/xsde/cxx/parser/expat/xml-error.cxx
@@ -13,13 +13,19 @@ namespace xsde
{
namespace expat
{
+ static const char* const text_[] =
+ {
+ "character unrepresentable in application encoding"
+ };
+
const char*
xml_error_text (xml_error e)
{
- return XML_ErrorString (e);
+ return e < 0x10000
+ ? XML_ErrorString (static_cast<XML_Error> (e))
+ : text_[e & 0xFFFF];
}
}
}
}
}
-
diff --git a/libxsde/xsde/cxx/parser/expat/xml-error.hxx b/libxsde/xsde/cxx/parser/expat/xml-error.hxx
index 6e28687..5871b48 100644
--- a/libxsde/xsde/cxx/parser/expat/xml-error.hxx
+++ b/libxsde/xsde/cxx/parser/expat/xml-error.hxx
@@ -8,6 +8,11 @@
#include <xsde/c/expat/expat.h>
+enum XML_Error_Ex
+{
+ XML_ERROR_UNREPRESENTABLE = 0x10000
+};
+
namespace xsde
{
namespace cxx
@@ -16,7 +21,10 @@ namespace xsde
{
namespace expat
{
- typedef XML_Error xml_error;
+ // The xml_error type can hold values from XML_Error and
+ // XML_Error_Ex enums.
+ //
+ typedef unsigned int xml_error;
const char*
xml_error_text (xml_error);
diff --git a/libxsde/xsde/cxx/serializer/context.cxx b/libxsde/xsde/cxx/serializer/context.cxx
index 650bed2..faa1ed4 100644
--- a/libxsde/xsde/cxx/serializer/context.cxx
+++ b/libxsde/xsde/cxx/serializer/context.cxx
@@ -3,6 +3,8 @@
// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <assert.h>
+
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/ro-string.hxx>
@@ -11,6 +13,10 @@
# include <xsde/cxx/serializer/exceptions.hxx>
#endif
+#ifdef XSDE_ENCODING_ISO8859_1
+# include <xsde/cxx/iso8859-1.hxx>
+#endif
+
#include <xsde/cxx/serializer/context.hxx>
namespace xsde
@@ -19,6 +25,625 @@ namespace xsde
{
namespace serializer
{
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ start_element (const char* name)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uname = name;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uname;
+ size_t un;
+ string buf;
+
+ if (iso8859_1::ascii_iso (name, un))
+ uname = name;
+ else
+ {
+ uname = conv_name (name, un, name_buf1_, buf);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uname == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxStartElementLiteral (
+ xml_serializer_,
+ 0,
+ reinterpret_cast<constUtf8> (uname));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ start_element (const char* ns, const char* name)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uns = ns;
+ const char* uname = name;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uns;
+ const char* uname;
+ size_t un;
+ string buf1, buf2;
+
+ if (iso8859_1::ascii_iso (ns, un))
+ uns = ns;
+ else
+ {
+ uns = conv_name (ns, un, name_buf1_, buf1);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uns == 0)
+ return false;
+#endif
+ }
+
+ if (iso8859_1::ascii_iso (name, un))
+ uname = name;
+ else
+ {
+ uname = conv_name (name, un, name_buf2_, buf2);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uname == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxStartElementLiteral (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (uns),
+ reinterpret_cast<constUtf8> (uname));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ start_attribute (const char* name)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uname = name;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uname;
+ size_t un;
+ string buf;
+
+ if (iso8859_1::ascii_iso (name, un))
+ uname = name;
+ else
+ {
+ uname = conv_name (name, un, name_buf1_, buf);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uname == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxStartAttributeLiteral (
+ xml_serializer_,
+ 0,
+ reinterpret_cast<constUtf8> (uname));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ start_attribute (const char* ns, const char* name)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uns = ns;
+ const char* uname = name;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uns;
+ const char* uname;
+ size_t un;
+ string buf1, buf2;
+
+ if (iso8859_1::ascii_iso (ns, un))
+ uns = ns;
+ else
+ {
+ uns = conv_name (ns, un, name_buf1_, buf1);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uns == 0)
+ return false;
+#endif
+ }
+
+ if (iso8859_1::ascii_iso (name, un))
+ uname = name;
+ else
+ {
+ uname = conv_name (name, un, name_buf2_, buf2);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uname == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxStartAttributeLiteral (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (uns),
+ reinterpret_cast<constUtf8> (uname));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ attribute (const char* name, const char* value)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uname = name;
+ const char* uvalue = value;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uname;
+ const char* uvalue;
+ size_t un;
+ string buf1, buf2;
+
+ if (iso8859_1::ascii_iso (name, un))
+ uname = name;
+ else
+ {
+ uname = conv_name (name, un, name_buf1_, buf1);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uname == 0)
+ return false;
+#endif
+ }
+
+ if (iso8859_1::ascii_iso (value, un))
+ uvalue = value;
+ else
+ {
+ uvalue = conv_data (value, un, buf2);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uvalue == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxAddAttributeLiteral (
+ xml_serializer_,
+ 0,
+ reinterpret_cast<constUtf8> (uname),
+ reinterpret_cast<constUtf8> (uvalue));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ attribute (const char* ns, const char* name, const char* value)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uns = ns;
+ const char* uname = name;
+ const char* uvalue = value;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uns;
+ const char* uname;
+ const char* uvalue;
+ size_t un;
+ string buf1, buf2, buf3;
+
+ if (iso8859_1::ascii_iso (ns, un))
+ uns = ns;
+ else
+ {
+ uns = conv_name (ns, un, name_buf1_, buf1);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uns == 0)
+ return false;
+#endif
+ }
+
+ if (iso8859_1::ascii_iso (name, un))
+ uname = name;
+ else
+ {
+ uname = conv_name (name, un, name_buf2_, buf2);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uname == 0)
+ return false;
+#endif
+ }
+
+ if (iso8859_1::ascii_iso (value, un))
+ uvalue = value;
+ else
+ {
+ uvalue = conv_data (value, un, buf3);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uvalue == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxAddAttributeLiteral (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (uns),
+ reinterpret_cast<constUtf8> (uname),
+ reinterpret_cast<constUtf8> (uvalue));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ characters (const char* s)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* us = s;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* us;
+ size_t un;
+ string buf;
+
+ if (iso8859_1::ascii_iso (s, un))
+ us = s;
+ else
+ {
+ us = conv_data (s, un, buf);
+
+#ifndef XSDE_EXCEPTIONS
+ if (us == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxAddText (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (us));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ characters (const char* s, size_t n)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* us = s;
+ size_t un = n;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* us;
+ size_t un;
+ string buf;
+
+ if (iso8859_1::ascii_iso (s, n, un))
+ {
+ us = s;
+ un = n;
+ }
+ else
+ {
+ us = conv_data (s, n, un, buf);
+
+#ifndef XSDE_EXCEPTIONS
+ if (us == 0)
+ return false;
+#endif
+ --un; // Discount trailing zero.
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxAddCountedText (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (us),
+ static_cast<int> (un));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ declare_namespace (const char* ns, const char* prefix)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uns = ns;
+ const char* uprefix = prefix;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uns;
+ const char* uprefix;
+ size_t un;
+ string buf1, buf2;
+
+ if (iso8859_1::ascii_iso (ns, un))
+ uns = ns;
+ else
+ {
+ uns = conv_name (ns, un, name_buf1_, buf1);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uns == 0)
+ return false;
+#endif
+ }
+
+ if (iso8859_1::ascii_iso (prefix, un))
+ uprefix = prefix;
+ else
+ {
+ uprefix = conv_name (prefix, un, name_buf2_, buf2);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uprefix == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxAddNamespaceLiteral (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (uns),
+ reinterpret_cast<constUtf8> (uprefix));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+#ifdef XSDE_EXCEPTIONS
+ void context::
+#else
+ bool context::
+#endif
+ declare_default_namespace (const char* ns)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uns = ns;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uns;
+ size_t un;
+ string buf;
+
+ if (iso8859_1::ascii_iso (ns, un))
+ uns = ns;
+ else
+ {
+ uns = conv_name (ns, un, name_buf1_, buf);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uns == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e = genxAddNamespaceLiteral (
+ xml_serializer_,
+ reinterpret_cast<constUtf8> (uns),
+ reinterpret_cast<constUtf8> (""));
+
+#ifdef XSDE_EXCEPTIONS
+ if (e != GENX_SUCCESS)
+ throw_xml_error (e);
+#else
+ if (e != GENX_SUCCESS)
+ xml_error (e);
+
+ return e == GENX_SUCCESS;
+#endif
+ }
+
+ //
+ //
+ const char* context::
+ lookup_namespace_prefix (const char* ns)
+ {
+ // Convert from application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ const char* uns = ns;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ const char* uns;
+ size_t un;
+ string buf;
+
+ if (iso8859_1::ascii_iso (ns, un))
+ uns = ns;
+ else
+ {
+ uns = conv_name (ns, un, name_buf1_, buf);
+
+#ifndef XSDE_EXCEPTIONS
+ if (uns == 0)
+ return false;
+#endif
+ }
+#endif // XSDE_ENCODING_*
+
+ genxStatus e;
+ genxNamespace gns = genxDeclareNamespace (
+ xml_serializer_, reinterpret_cast<constUtf8> (uns), 0, &e);
+
+ if (e != GENX_SUCCESS)
+ {
+#ifdef XSDE_EXCEPTIONS
+ throw_xml_error (e);
+#else
+ xml_error (e);
+#endif
+ return 0;
+ }
+
+ const char* p = reinterpret_cast<const char*> (
+ genxGetNamespacePrefix (gns));
+
+ // Convert to application encoding.
+ //
+#ifdef XSDE_ENCODING_UTF8
+ return p;
+#elif defined(XSDE_ENCODING_ISO8859_1)
+ // At the moment we can only support ASCII prefixes since there is
+ // no good way to store the converted string.
+ //
+ assert (iso8859_1::ascii_utf (p, un));
+ return p;
+#endif // XSDE_ENCODING_*
+ }
+
+ //
+ //
#ifdef XSDE_POLYMORPHIC
#ifdef XSDE_EXCEPTIONS
void context::
@@ -102,6 +727,83 @@ namespace xsde
}
}
#endif
+
+#ifdef XSDE_ENCODING_ISO8859_1
+ const char* context::
+ conv_data (const char* iso_s, size_t utf_n, string& var)
+ {
+ char* buf;
+
+ if (utf_n <= sizeof (data_buf_))
+ buf = data_buf_;
+ else
+ {
+ buf = new char[utf_n];
+
+#ifndef XSDE_EXCEPTIONS
+ if (buf == 0)
+ {
+ sys_error (sys_error::no_memory);
+ return 0;
+ }
+#endif
+ var.attach (buf, utf_n - 1);
+ }
+
+ iso8859_1::from (iso_s, buf);
+ return buf;
+ }
+
+ const char* context::
+ conv_data (const char* iso_s, size_t iso_n, size_t utf_n, string& var)
+ {
+ char* buf;
+
+ if (utf_n <= sizeof (data_buf_))
+ buf = data_buf_;
+ else
+ {
+ buf = new char[utf_n];
+
+#ifndef XSDE_EXCEPTIONS
+ if (buf == 0)
+ {
+ sys_error (sys_error::no_memory);
+ return 0;
+ }
+#endif
+ var.attach (buf, utf_n - 1);
+ }
+
+ iso8859_1::from (iso_s, iso_n, buf);
+ return buf;
+ }
+
+ const char* context::
+ conv_name (const char* iso_s, size_t utf_n, char* fix, string& var)
+ {
+ char* buf;
+
+ if (utf_n <= sizeof (name_buf1_))
+ buf = fix;
+ else
+ {
+ buf = new char[utf_n];
+
+#ifndef XSDE_EXCEPTIONS
+ if (buf == 0)
+ {
+ sys_error (sys_error::no_memory);
+ return 0;
+ }
+#endif
+ var.attach (buf, utf_n - 1);
+ }
+
+ iso8859_1::from (iso_s, buf);
+ return buf;
+ }
+#endif // XSDE_ENCODING_ISO8859_1
}
}
}
diff --git a/libxsde/xsde/cxx/serializer/context.hxx b/libxsde/xsde/cxx/serializer/context.hxx
index d09bb4d..d2cec00 100644
--- a/libxsde/xsde/cxx/serializer/context.hxx
+++ b/libxsde/xsde/cxx/serializer/context.hxx
@@ -11,6 +11,7 @@
#include <stddef.h> // size_t
#include <xsde/c/genx/genx.h>
+#include <xsde/cxx/string.hxx>
#ifndef XSDE_EXCEPTIONS
# include <xsde/cxx/sys-error.hxx>
@@ -251,6 +252,23 @@ namespace xsde
const void* type_id_;
#endif
+ // Support for ISO-8859-1 conversion.
+ //
+#ifdef XSDE_ENCODING_ISO8859_1
+ protected:
+ const char*
+ conv_data (const char* iso_s, size_t utf_n, string& var);
+
+ const char*
+ conv_data (const char* iso_s, size_t iso_n, size_t utf_n, string& var);
+
+ const char*
+ conv_name (const char* iso_s, size_t utf_n, char* fix, string& var);
+
+ char data_buf_[256];
+ char name_buf1_[128];
+ char name_buf2_[128]; // Keep buf1 and buf2 sizes the same.
+#endif
};
}
}
diff --git a/libxsde/xsde/cxx/serializer/context.ixx b/libxsde/xsde/cxx/serializer/context.ixx
index 04cfe87..3612f0a 100644
--- a/libxsde/xsde/cxx/serializer/context.ixx
+++ b/libxsde/xsde/cxx/serializer/context.ixx
@@ -45,56 +45,6 @@ namespace xsde
#else
inline bool context::
#endif
- start_element (const char* name)
- {
- genxStatus e = genxStartElementLiteral (
- xml_serializer_,
- 0,
- reinterpret_cast<constUtf8> (name));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- start_element (const char* ns, const char* name)
- {
- genxStatus e = genxStartElementLiteral (
- xml_serializer_,
- reinterpret_cast<constUtf8> (ns),
- reinterpret_cast<constUtf8> (name));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
end_element ()
{
genxStatus e = genxEndElement (xml_serializer_);
@@ -117,56 +67,6 @@ namespace xsde
#else
inline bool context::
#endif
- start_attribute (const char* name)
- {
- genxStatus e = genxStartAttributeLiteral (
- xml_serializer_,
- 0,
- reinterpret_cast<constUtf8> (name));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- start_attribute (const char* ns, const char* name)
- {
- genxStatus e = genxStartAttributeLiteral (
- xml_serializer_,
- reinterpret_cast<constUtf8> (ns),
- reinterpret_cast<constUtf8> (name));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
end_attribute ()
{
genxStatus e = genxEndAttribute (xml_serializer_);
@@ -189,157 +89,6 @@ namespace xsde
#else
inline bool context::
#endif
- attribute (const char* name, const char* value)
- {
- genxStatus e = genxAddAttributeLiteral (
- xml_serializer_,
- 0,
- reinterpret_cast<constUtf8> (name),
- reinterpret_cast<constUtf8> (value));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- attribute (const char* ns, const char* name, const char* value)
- {
- genxStatus e = genxAddAttributeLiteral (
- xml_serializer_,
- reinterpret_cast<constUtf8> (ns),
- reinterpret_cast<constUtf8> (name),
- reinterpret_cast<constUtf8> (value));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- characters (const char* s)
- {
- genxStatus e = genxAddText (
- xml_serializer_,
- reinterpret_cast<constUtf8> (s));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- characters (const char* s, size_t n)
- {
- genxStatus e = genxAddCountedText (
- xml_serializer_,
- reinterpret_cast<constUtf8> (s),
- static_cast<int> (n));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- declare_namespace (const char* ns, const char* prefix)
- {
- genxStatus e = genxAddNamespaceLiteral (
- xml_serializer_,
- reinterpret_cast<constUtf8> (ns),
- reinterpret_cast<constUtf8> (prefix));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
- declare_default_namespace (const char* ns)
- {
- genxStatus e = genxAddNamespaceLiteral (
- xml_serializer_,
- reinterpret_cast<constUtf8> (ns),
- reinterpret_cast<constUtf8> (""));
-
-#ifdef XSDE_EXCEPTIONS
- if (e != GENX_SUCCESS)
- throw_xml_error (e);
-#else
- if (e != GENX_SUCCESS)
- xml_error (e);
-
- return e == GENX_SUCCESS;
-#endif
- }
-
- //
- //
-#ifdef XSDE_EXCEPTIONS
- inline void context::
-#else
- inline bool context::
-#endif
clear_default_namespace ()
{
genxStatus e = genxUnsetDefaultNamespace (xml_serializer_);
@@ -357,29 +106,6 @@ namespace xsde
//
//
- inline const char* context::
- lookup_namespace_prefix (const char* ns)
- {
- genxStatus e;
- genxNamespace gns = genxDeclareNamespace (
- xml_serializer_, reinterpret_cast<constUtf8> (ns), 0, &e);
-
- if (e != GENX_SUCCESS)
- {
-#ifdef XSDE_EXCEPTIONS
- throw_xml_error (e);
-#else
- xml_error (e);
-#endif
- return 0;
- }
-
- return reinterpret_cast<const char*> (
- genxGetNamespacePrefix (gns));
- }
-
- //
- //
#ifndef XSDE_EXCEPTIONS
inline int context::
app_error () const
diff --git a/libxsde/xsde/makefile b/libxsde/xsde/makefile
index 468d19e..3a0465c 100644
--- a/libxsde/xsde/makefile
+++ b/libxsde/xsde/makefile
@@ -10,6 +10,10 @@ c_tun += c/genx/genx.c c/genx/char-props.c
cxx_tun := cxx/string.cxx cxx/ro-string.cxx cxx/stack.cxx
+ifeq ($(xsde_encoding),iso8859-1)
+cxx_tun += cxx/iso8859-1.cxx
+endif
+
ifeq ($(xsde_stl),n)
cxx_tun += cxx/strdupx.cxx
endif
@@ -517,6 +521,16 @@ ifeq ($(xsde_byteorder),l)
else
@echo '#define XSDE_BYTEORDER 4321' >>$@
endif
+ifeq ($(xsde_encoding),utf8)
+ @echo '#define XSDE_ENCODING_UTF8' >>$@
+else
+ @echo '#undef XSDE_ENCODING_UTF8' >>$@
+endif
+ifeq ($(xsde_encoding),iso8859-1)
+ @echo '#define XSDE_ENCODING_ISO8859_1' >>$@
+else
+ @echo '#undef XSDE_ENCODING_ISO8859_1' >>$@
+endif
ifeq ($(xsde_stl),y)
@echo '#define XSDE_STL' >>$@
else
diff --git a/tests/cxx/hybrid/iso8859-1/driver.cxx b/tests/cxx/hybrid/iso8859-1/driver.cxx
new file mode 100644
index 0000000..ec68dbf
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/driver.cxx
@@ -0,0 +1,95 @@
+// file : tests/cxx/hybrid/iso8859-1/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test support for the ISO-8859-1 encoding.
+//
+
+#include <assert.h>
+
+#include <string>
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.hxx"
+
+#include <xsde/cxx/iso8859-1.hxx>
+
+using namespace std;
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+#ifdef XSDE_EXCEPTIONS
+ try
+ {
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+ assert (false);
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ // cerr << e.line () << ":" << e.column () << ": " << e.text () << endl;
+ }
+#else
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ assert (doc_p._error ());
+#endif
+
+ doc_p.reset ();
+ xml_schema::iso8859_1::unrep_char ('?');
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ assert (r->a ()[0] == string ("abc"));
+ assert (r->a ()[1] == string ("\xE6"));
+ assert (r->a ()[2] == string ("\xA2\xA3\xA4\xA5"));
+ assert (r->a ()[3] == string ("???"));
+ assert (r->a ()[4] == string ("longlonglonglonglonglonglonglonglonglonglonglong\xE6longlonglonglong"));
+
+ assert (r->b ()[0] == strenum::abc);
+ assert (r->b ()[1] == strenum::a_c);
+ assert (r->b ()[1].string () == string ("a\xE2""c"));
+ assert (r->b ()[2] == strenum::cxx__bc);
+
+ assert (r->element_name_with_special_char__ () == string ("longlonglong\xA2\xA3\xA4\xA5longlong"));
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/iso8859-1/makefile b/tests/cxx/hybrid/iso8859-1/makefile
new file mode 100644
index 0000000..2cc1f57
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/makefile
@@ -0,0 +1,108 @@
+# file : tests/cxx/hybrid/iso8859-1/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen) $(dist) $(dist-win): xsde_options += --generate-parser \
+--generate-serializer --generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test-000.xml $(src_base)/test-000.std
+ $(call message,test $$1,$$1 $(src_base)/test-000.xml | diff -u $(src_base)/test-000.std -,$(driver))
+
+
+# Dist.
+#
+$(dist) $(dist-win): opt := -src $(src_base) -cmd cxx-hybrid -xsd "$(xsd)" \
+-cxx "$(cxx)" -gen "$(genf)" -opt "$(xsde_options)" -out $(dist_prefix)
+
+$(dist):
+ $(call message,install $(src_base),$(scf_root)/dist $(opt))
+
+$(dist-win):
+ $(call message,install $(src_base),$(scf_root)/dist -win $(opt))
+
+
+# Clean.
+#
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/iso8859-1/test-000.std b/tests/cxx/hybrid/iso8859-1/test-000.std
new file mode 100644
index 0000000..2631b99
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/test-000.std
@@ -0,0 +1 @@
+<t:root xmlns:t="test" x="longlonglong¢£¤¥longlong"><a>abc</a><a>æ</a><a>¢£¤¥</a><a>???</a><a>longlonglonglonglonglonglonglonglonglonglonglongælonglonglonglong</a><b>abc</b><b>aâc</b><b>âòbc</b><element_name_with_special_char_â>longlonglong¢£¤¥longlong</element_name_with_special_char_â></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/iso8859-1/test-000.xml b/tests/cxx/hybrid/iso8859-1/test-000.xml
new file mode 100644
index 0000000..fd61446
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/test-000.xml
@@ -0,0 +1,15 @@
+<t:root xmlns:t="test" x="longlonglong&#xA2;&#xA3;&#xA4;&#xA5;longlong">
+
+ <a>abc</a>
+ <a>&#xE6;</a>
+ <a>&#xA2;&#xA3;&#xA4;&#xA5;</a>
+ <a>&#x100;&#xAAAA;&#xAAAAA;</a>
+ <a>longlonglonglonglonglonglonglonglonglonglonglong&#xE6;longlonglonglong</a>
+
+ <b>abc</b>
+ <b>a&#xE2;c</b>
+ <b>&#xE2;&#xF2;bc</b>
+
+ <element_name_with_special_char_â>longlonglong&#xA2;&#xA3;&#xA4;&#xA5;longlong</element_name_with_special_char_â>
+
+</t:root>
diff --git a/tests/cxx/hybrid/iso8859-1/test.xsd b/tests/cxx/hybrid/iso8859-1/test.xsd
new file mode 100644
index 0000000..242b84a
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/test.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="strenum">
+ <restriction base="string">
+ <enumeration value="abc"/>
+ <enumeration value="a&#xE2;c"/>
+ <enumeration value="&#xE2;&#xF2;bc"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="a" type="string" maxOccurs="unbounded"/>
+ <element name="b" type="t:strenum" maxOccurs="unbounded"/>
+ <element name="element_name_with_special_char_&#xE2;" type="string"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile
index 60960c3..8fb3f3f 100644
--- a/tests/cxx/hybrid/makefile
+++ b/tests/cxx/hybrid/makefile
@@ -10,7 +10,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
#
all_tests := sequences polymorphism iterator built-in default enumeration \
-list recursive test-template union binary/cdr binary/xdr choice
+iso8859-1 list recursive test-template union binary/cdr binary/xdr choice
build_tests := sequences
@@ -27,6 +27,10 @@ endif
ifeq ($(xsde_iostream),y)
build_tests += built-in default enumeration list test-template union
+ifeq ($(xsde_encoding),iso8859-1)
+build_tests += iso8859-1
+endif
+
ifeq ($(xsde_cdr),y)
build_tests += binary/cdr
endif
diff --git a/xsde/cxx/elements.cxx b/xsde/cxx/elements.cxx
index be65fc1..f8d7132 100644
--- a/xsde/cxx/elements.cxx
+++ b/xsde/cxx/elements.cxx
@@ -114,6 +114,7 @@ namespace CXX
SemanticGraph::Schema& root,
Char const* name_key,
NarrowString const& char_type__,
+ NarrowString const& char_encoding__,
Boolean include_with_brackets__,
NarrowString const& include_prefix__,
NarrowString const& esymbol,
@@ -128,6 +129,7 @@ namespace CXX
schema_root (root),
ename_key (ename_key_),
char_type (char_type_),
+ char_encoding (char_encoding_),
L (L_),
string_type (string_type_),
include_with_brackets (include_with_brackets_),
@@ -139,6 +141,7 @@ namespace CXX
xs_ns_ (0),
ename_key_ (name_key),
char_type_ (char_type__),
+ char_encoding_ (char_encoding__),
L_ (char_type == L"wchar_t" ? L"L" : L""),
include_with_brackets_ (include_with_brackets__),
include_prefix_ (include_prefix__),
@@ -819,6 +822,126 @@ namespace CXX
}
String
+ strlit_iso8859_1 (String const& str)
+ {
+ String r;
+ Size n (str.size ());
+
+ // In most common cases we will have that many chars.
+ //
+ r.reserve (n + 2);
+
+ r += '"';
+
+ Boolean escape (false);
+
+ for (Size i (0); i < n; ++i)
+ {
+ UnsignedLong u (Context::unicode_char (str, i)); // May advance i.
+
+ // [256 - ] - unrepresentable
+ // [127 - 255] - \xXX
+ // [32 - 126] - as is
+ // [0 - 31] - \X or \xXX
+ //
+
+ if (u < 32)
+ {
+ switch (u)
+ {
+ case L'\n':
+ {
+ r += L"\\n";
+ break;
+ }
+ case L'\t':
+ {
+ r += L"\\t";
+ break;
+ }
+ case L'\v':
+ {
+ r += L"\\v";
+ break;
+ }
+ case L'\b':
+ {
+ r += L"\\b";
+ break;
+ }
+ case L'\r':
+ {
+ r += L"\\r";
+ break;
+ }
+ case L'\f':
+ {
+ r += L"\\f";
+ break;
+ }
+ case L'\a':
+ {
+ r += L"\\a";
+ break;
+ }
+ default:
+ {
+ r += charlit (u);
+ escape = true;
+ break;
+ }
+ }
+ }
+ else if (u < 127)
+ {
+ if (escape)
+ {
+ // Close and open the string so there are no clashes.
+ //
+ r += '"';
+ r += '"';
+
+ escape = false;
+ }
+
+ switch (u)
+ {
+ case L'"':
+ {
+ r += L"\\\"";
+ break;
+ }
+ case L'\\':
+ {
+ r += L"\\\\";
+ break;
+ }
+ default:
+ {
+ r += static_cast<WideChar> (u);
+ break;
+ }
+ }
+ }
+ else if (u < 256)
+ {
+ r += charlit (u);
+ escape = true;
+ }
+ else
+ {
+ // Unrepresentable character.
+ //
+ throw UnrepresentableCharacter (str, i + 1);
+ }
+ }
+
+ r += '"';
+
+ return r;
+ }
+
+ String
strlit_utf32 (String const& str)
{
String r;
@@ -936,7 +1059,12 @@ namespace CXX
strlit (String const& str)
{
if (char_type == L"char")
- return strlit_utf8 (str);
+ {
+ if (char_encoding == L"iso8859-1")
+ return strlit_iso8859_1 (str);
+ else
+ return strlit_utf8 (str);
+ }
else
return strlit_utf32 (str);
}
diff --git a/xsde/cxx/elements.hxx b/xsde/cxx/elements.hxx
index d5c5a3c..67b51db 100644
--- a/xsde/cxx/elements.hxx
+++ b/xsde/cxx/elements.hxx
@@ -35,6 +35,30 @@ namespace CXX
// Exceptions.
//
+ struct UnrepresentableCharacter
+ {
+ UnrepresentableCharacter (String const& str, Size pos)
+ : str_ (str), pos_ (pos)
+ {
+ }
+
+ String const&
+ string () const
+ {
+ return str_;
+ }
+
+ Size
+ position () const
+ {
+ return pos_;
+ }
+
+ private:
+ String str_;
+ Size pos_;
+ };
+
struct NoNamespaceMapping
{
NoNamespaceMapping (SemanticGraph::Path const& file,
@@ -124,6 +148,7 @@ namespace CXX
SemanticGraph::Schema& root,
Char const* name_key,
NarrowString const& char_type__,
+ NarrowString const& char_encoding__,
Boolean include_with_brackets__,
NarrowString const& include_prefix__,
NarrowString const& esymbol,
@@ -141,6 +166,7 @@ namespace CXX
schema_root (c.schema_root),
ename_key (c.ename_key),
char_type (c.char_type),
+ char_encoding (c.char_encoding),
L (c.L),
string_type (c.string_type),
include_with_brackets (c.include_with_brackets),
@@ -167,6 +193,7 @@ namespace CXX
schema_root (c.schema_root),
ename_key (c.ename_key),
char_type (c.char_type),
+ char_encoding (c.char_encoding),
L (c.L),
string_type (c.string_type),
include_with_brackets (c.include_with_brackets),
@@ -296,6 +323,7 @@ namespace CXX
NarrowString const& ename_key;
String& char_type;
+ String& char_encoding;
String& L; // string literal prefix
String& string_type;
@@ -315,6 +343,7 @@ namespace CXX
NarrowString const ename_key_;
String char_type_;
+ String char_encoding_;
String L_;
String string_type_;
diff --git a/xsde/cxx/hybrid/cli.hxx b/xsde/cxx/hybrid/cli.hxx
index ff89942..3834767 100644
--- a/xsde/cxx/hybrid/cli.hxx
+++ b/xsde/cxx/hybrid/cli.hxx
@@ -23,6 +23,7 @@ namespace CXX
typedef Char const Key[];
+ extern Key char_encoding;
extern Key no_stl;
extern Key no_iostream;
extern Key no_exceptions;
@@ -112,6 +113,7 @@ namespace CXX
extern Key proprietary_license;
typedef Cult::CLI::Options<
+ char_encoding, NarrowString,
no_stl, Boolean,
no_iostream, Boolean,
no_exceptions, Boolean,
diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx
index e08cf8b..27e983a 100644
--- a/xsde/cxx/hybrid/elements.cxx
+++ b/xsde/cxx/hybrid/elements.cxx
@@ -20,6 +20,7 @@ namespace CXX
root,
"name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx
index 311d5d7..14cba6a 100644
--- a/xsde/cxx/hybrid/generator.cxx
+++ b/xsde/cxx/hybrid/generator.cxx
@@ -111,6 +111,7 @@ namespace CXX
{
namespace CLI
{
+ extern Key char_encoding = "char-encoding";
extern Key no_stl = "no-stl";
extern Key no_iostream = "no-iostream";
extern Key no_exceptions = "no-exceptions";
@@ -207,6 +208,12 @@ namespace CXX
std::wostream& e (wcerr);
::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e);
+ e << "--char-encoding <enc>" << endl
+ << " Specify the character encoding that should be\n"
+ << " used in the object model. Valid values are 'utf8'\n"
+ << " (default) and 'iso8859-1'."
+ << endl;
+
e << "--no-stl" << endl
<< " Generate code that does not use STL."
<< endl;
@@ -704,6 +711,8 @@ namespace CXX
{
CLI::OptionsSpec spec;
+ spec.option<CLI::char_encoding> ().default_value ("utf8");
+
spec.option<CLI::pskel_file_suffix> ().default_value ("-pskel");
spec.option<CLI::sskel_file_suffix> ().default_value ("-sskel");
spec.option<CLI::pskel_type_suffix> ().default_value ("_pskel");
@@ -814,6 +823,7 @@ namespace CXX
Evptr<P::Options> r (new P::Options);
+ r->value<P::char_encoding> () = h.value<H::char_encoding> ();
r->value<P::no_stl> () = h.value<H::no_stl> ();
r->value<P::no_iostream> () = h.value<H::no_iostream> ();
r->value<P::no_exceptions> () = h.value<H::no_exceptions> ();
@@ -895,6 +905,7 @@ namespace CXX
Evptr<S::Options> r (new S::Options);
+ r->value<S::char_encoding> () = h.value<H::char_encoding> ();
r->value<S::no_stl> () = h.value<H::no_stl> ();
r->value<S::no_iostream> () = h.value<H::no_iostream> ();
r->value<S::no_exceptions> () = h.value<H::no_exceptions> ();
@@ -1527,6 +1538,25 @@ namespace CXX
hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
+ if (ops.value<CLI::char_encoding> () == "iso8859-1")
+ {
+ hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
+ << "#error the generated code uses the ISO-8859-1 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
+ << "#error the generated code uses the UTF-8 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
if (ops.value<CLI::no_stl> ())
{
hxx << "#ifdef XSDE_STL" << endl
@@ -2613,6 +2643,14 @@ namespace CXX
return sloc;
}
+ catch (UnrepresentableCharacter const& e)
+ {
+ wcerr << "error: character at position " << e.position () << " "
+ << "in string '" << e.string () << "' is unrepresentable in "
+ << "the target encoding" << endl;
+
+ throw Failed ();
+ }
catch (NoNamespaceMapping const& e)
{
wcerr << e.file () << ":" << e.line () << ":" << e.column ()
diff --git a/xsde/cxx/hybrid/parser-name-processor.cxx b/xsde/cxx/hybrid/parser-name-processor.cxx
index a8d3639..afb0df4 100644
--- a/xsde/cxx/hybrid/parser-name-processor.cxx
+++ b/xsde/cxx/hybrid/parser-name-processor.cxx
@@ -36,6 +36,7 @@ namespace CXX
root,
"name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/hybrid/serializer-name-processor.cxx b/xsde/cxx/hybrid/serializer-name-processor.cxx
index 34f205a..5da88b9 100644
--- a/xsde/cxx/hybrid/serializer-name-processor.cxx
+++ b/xsde/cxx/hybrid/serializer-name-processor.cxx
@@ -35,6 +35,7 @@ namespace CXX
root,
"name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/hybrid/tree-name-processor.cxx b/xsde/cxx/hybrid/tree-name-processor.cxx
index 2ee30ef..b2a2c69 100644
--- a/xsde/cxx/hybrid/tree-name-processor.cxx
+++ b/xsde/cxx/hybrid/tree-name-processor.cxx
@@ -38,6 +38,7 @@ namespace CXX
root,
"name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/hybrid/tree-type-map.cxx b/xsde/cxx/hybrid/tree-type-map.cxx
index 5f1c36b..1b22ff9 100644
--- a/xsde/cxx/hybrid/tree-type-map.cxx
+++ b/xsde/cxx/hybrid/tree-type-map.cxx
@@ -27,6 +27,7 @@ namespace CXX
root,
"name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/hybrid/validator.cxx b/xsde/cxx/hybrid/validator.cxx
index f95bd96..716f072 100644
--- a/xsde/cxx/hybrid/validator.cxx
+++ b/xsde/cxx/hybrid/validator.cxx
@@ -489,6 +489,18 @@ namespace CXX
Boolean valid (true);
ValidationContext ctx (root, options, disabled_warnings, valid);
+ //
+ //
+ NarrowString enc (options.value<CLI::char_encoding> ());
+
+ if (enc != "utf8" && enc != "iso8859-1")
+ {
+ wcerr << "error: unknown encoding '" << enc.c_str () << "'" << endl;
+ return false;
+ }
+
+ //
+ //
Boolean par (options.value<CLI::generate_parser> ());
Boolean ser (options.value<CLI::generate_serializer> ());
Boolean agg (options.value<CLI::generate_aggregate> ());
diff --git a/xsde/cxx/parser/cli.hxx b/xsde/cxx/parser/cli.hxx
index 62a1891..a50c3ff 100644
--- a/xsde/cxx/parser/cli.hxx
+++ b/xsde/cxx/parser/cli.hxx
@@ -24,6 +24,7 @@ namespace CXX
typedef Char const Key[];
extern Key type_map;
+ extern Key char_encoding;
extern Key no_stl;
extern Key no_iostream;
extern Key no_exceptions;
@@ -86,6 +87,7 @@ namespace CXX
typedef Cult::CLI::Options<
type_map, Cult::Containers::Vector<NarrowString>,
+ char_encoding, NarrowString,
no_stl, Boolean,
no_iostream, Boolean,
no_exceptions, Boolean,
diff --git a/xsde/cxx/parser/elements.cxx b/xsde/cxx/parser/elements.cxx
index 4b624ff..3c62b5b 100644
--- a/xsde/cxx/parser/elements.cxx
+++ b/xsde/cxx/parser/elements.cxx
@@ -20,6 +20,7 @@ namespace CXX
root,
"p:name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx
index e59180c..1936286 100644
--- a/xsde/cxx/parser/generator.cxx
+++ b/xsde/cxx/parser/generator.cxx
@@ -113,6 +113,7 @@ namespace CXX
namespace CLI
{
extern Key type_map = "type-map";
+ extern Key char_encoding = "char-encoding";
extern Key no_stl = "no-stl";
extern Key no_iostream = "no-iostream";
extern Key no_exceptions = "no-exceptions";
@@ -188,6 +189,12 @@ namespace CXX
<< " order of appearance and the first match is used."
<< endl;
+ e << "--char-encoding <enc>" << endl
+ << " Specify the character encoding that should be\n"
+ << " used for the extracted text data. Valid values\n"
+ << " are 'utf8' (default) and 'iso8859-1'."
+ << endl;
+
e << "--no-stl" << endl
<< " Generate code that does not use STL."
<< endl;
@@ -514,6 +521,8 @@ namespace CXX
{
CLI::OptionsSpec spec;
+ spec.option<CLI::char_encoding> ().default_value ("utf8");
+
spec.option<CLI::skel_file_suffix> ().default_value ("-pskel");
spec.option<CLI::skel_type_suffix> ().default_value ("_pskel");
spec.option<CLI::impl_file_suffix> ().default_value ("-pimpl");
@@ -1207,6 +1216,25 @@ namespace CXX
hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
+ if (ops.value<CLI::char_encoding> () == "iso8859-1")
+ {
+ hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
+ << "#error the generated code uses the ISO-8859-1 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
+ << "#error the generated code uses the UTF-8 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
if (ops.value<CLI::no_stl> ())
{
hxx << "#ifdef XSDE_STL" << endl
@@ -1585,6 +1613,14 @@ namespace CXX
return sloc;
}
+ catch (UnrepresentableCharacter const& e)
+ {
+ wcerr << "error: character at position " << e.position () << " "
+ << "in string '" << e.string () << "' is unrepresentable in "
+ << "the target encoding" << endl;
+
+ throw Failed ();
+ }
catch (NoNamespaceMapping const& e)
{
wcerr << e.file () << ":" << e.line () << ":" << e.column ()
diff --git a/xsde/cxx/parser/name-processor.cxx b/xsde/cxx/parser/name-processor.cxx
index 658b70a..a168c28 100644
--- a/xsde/cxx/parser/name-processor.cxx
+++ b/xsde/cxx/parser/name-processor.cxx
@@ -34,6 +34,7 @@ namespace CXX
root,
"p:name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/parser/parser-header.cxx b/xsde/cxx/parser/parser-header.cxx
index f3dd45c..6ef9578 100644
--- a/xsde/cxx/parser/parser-header.cxx
+++ b/xsde/cxx/parser/parser-header.cxx
@@ -1634,6 +1634,14 @@ namespace CXX
<< "typedef xsde::cxx::parser::context parser_context;"
<< endl;
+ if (char_encoding == L"iso8859-1")
+ {
+ os << "// ISO-8859-1 transcoder." << endl
+ << "//" << endl
+ << "using xsde::cxx::iso8859_1;"
+ << endl;
+ }
+
post (ns);
}
};
@@ -1675,8 +1683,12 @@ namespace CXX
else
{
ctx.os << "#include <xsde/config.h>" << endl
- << "#include <xsde/cxx/ro-string.hxx>" << endl
- << endl;
+ << "#include <xsde/cxx/ro-string.hxx>" << endl;
+
+ if (ctx.char_encoding == L"iso8859-1")
+ ctx.os << "#include <xsde/cxx/iso8859-1.hxx>" << endl;
+
+ ctx.os << endl;
// Data types.
//
diff --git a/xsde/cxx/parser/validator.cxx b/xsde/cxx/parser/validator.cxx
index 96170de..33fe2e2 100644
--- a/xsde/cxx/parser/validator.cxx
+++ b/xsde/cxx/parser/validator.cxx
@@ -601,6 +601,16 @@ namespace CXX
//
//
+ NarrowString enc (options.value<CLI::char_encoding> ());
+
+ if (enc != "utf8" && enc != "iso8859-1")
+ {
+ wcerr << "error: unknown encoding '" << enc.c_str () << "'" << endl;
+ return false;
+ }
+
+ //
+ //
if (options.value<CLI::generate_noop_impl> () &&
options.value<CLI::generate_print_impl> ())
{
diff --git a/xsde/cxx/serializer/cli.hxx b/xsde/cxx/serializer/cli.hxx
index 41bdde2..d65ca1a 100644
--- a/xsde/cxx/serializer/cli.hxx
+++ b/xsde/cxx/serializer/cli.hxx
@@ -24,6 +24,7 @@ namespace CXX
typedef Char const Key[];
extern Key type_map;
+ extern Key char_encoding;
extern Key no_stl;
extern Key no_iostream;
extern Key no_exceptions;
@@ -85,6 +86,7 @@ namespace CXX
typedef Cult::CLI::Options<
type_map, Cult::Containers::Vector<NarrowString>,
+ char_encoding, NarrowString,
no_stl, Boolean,
no_iostream, Boolean,
no_exceptions, Boolean,
diff --git a/xsde/cxx/serializer/elements.cxx b/xsde/cxx/serializer/elements.cxx
index 495b867..f59a102 100644
--- a/xsde/cxx/serializer/elements.cxx
+++ b/xsde/cxx/serializer/elements.cxx
@@ -20,6 +20,7 @@ namespace CXX
root,
"s:name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index c15d603..cf6091d 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -111,6 +111,7 @@ namespace CXX
namespace CLI
{
extern Key type_map = "type-map";
+ extern Key char_encoding = "char-encoding";
extern Key no_stl = "no-stl";
extern Key no_iostream = "no-iostream";
extern Key no_exceptions = "no-exceptions";
@@ -185,6 +186,12 @@ namespace CXX
<< " order of appearance and the first match is used."
<< endl;
+ e << "--char-encoding <enc>" << endl
+ << " Specify the character encoding that is used in\n"
+ << " the text data being serialized. Valid values are\n"
+ << " 'utf8' (default) and 'iso8859-1'."
+ << endl;
+
e << "--no-stl" << endl
<< " Generate code that does not use STL."
<< endl;
@@ -507,6 +514,8 @@ namespace CXX
{
CLI::OptionsSpec spec;
+ spec.option<CLI::char_encoding> ().default_value ("utf8");
+
spec.option<CLI::skel_file_suffix> ().default_value ("-sskel");
spec.option<CLI::skel_type_suffix> ().default_value ("_sskel");
spec.option<CLI::impl_file_suffix> ().default_value ("-simpl");
@@ -1193,6 +1202,25 @@ namespace CXX
hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
+ if (ops.value<CLI::char_encoding> () == "iso8859-1")
+ {
+ hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl
+ << "#error the generated code uses the ISO-8859-1 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+ else
+ {
+ hxx << "#ifndef XSDE_ENCODING_UTF8" << endl
+ << "#error the generated code uses the UTF-8 encoding" <<
+ "while the XSD/e runtime does not (reconfigure the runtime " <<
+ "or change the --char-encoding value)" << endl
+ << "#endif" << endl
+ << endl;
+ }
+
if (ops.value<CLI::no_stl> ())
{
hxx << "#ifdef XSDE_STL" << endl
@@ -1570,6 +1598,14 @@ namespace CXX
return sloc;
}
+ catch (UnrepresentableCharacter const& e)
+ {
+ wcerr << "error: character at position " << e.position () << " "
+ << "in string '" << e.string () << "' is unrepresentable in "
+ << "the target encoding" << endl;
+
+ throw Failed ();
+ }
catch (NoNamespaceMapping const& e)
{
wcerr << e.file () << ":" << e.line () << ":" << e.column ()
diff --git a/xsde/cxx/serializer/name-processor.cxx b/xsde/cxx/serializer/name-processor.cxx
index e388169..ddc9c4e 100644
--- a/xsde/cxx/serializer/name-processor.cxx
+++ b/xsde/cxx/serializer/name-processor.cxx
@@ -34,6 +34,7 @@ namespace CXX
root,
"s:name",
"char",
+ ops.value<CLI::char_encoding> (),
ops.value<CLI::include_with_brackets> (),
ops.value<CLI::include_prefix> (),
"", // export symbol
diff --git a/xsde/cxx/serializer/validator.cxx b/xsde/cxx/serializer/validator.cxx
index 50948b9..c163459 100644
--- a/xsde/cxx/serializer/validator.cxx
+++ b/xsde/cxx/serializer/validator.cxx
@@ -410,6 +410,16 @@ namespace CXX
//
//
+ NarrowString enc (options.value<CLI::char_encoding> ());
+
+ if (enc != "utf8" && enc != "iso8859-1")
+ {
+ wcerr << "error: unknown encoding '" << enc.c_str () << "'" << endl;
+ return false;
+ }
+
+ //
+ //
{
Boolean ref (options.value<CLI::root_element_first> ());
Boolean rel (options.value<CLI::root_element_last> ());