# -*- coding: utf-8 -*-
import logging
if __name__ == '__main__':
    logging.basicConfig()
_log = logging.getLogger(__name__)

import pyxb.binding.generate
import pyxb.binding.datatypes as xs
import pyxb.binding.basis
import pyxb.utils.domutils

import os.path
xsd=u'''<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:simpleType name="tEnum">
                <xs:restriction base="xs:token">
                        <xs:enumeration value="%s"/> > <!-- u'\xb0' -->
                        <xs:enumeration value="m%s"/>
                        <xs:enumeration value="m%s"/>
                </xs:restriction>
        </xs:simpleType>
</xs:schema>
''' % (u'\xb0', u'\xb2', u'\xb3')

#open('schema.xsd', 'w').write(xsd)
code = pyxb.binding.generate.GeneratePython(schema_text=xsd)
#open('code.py', 'w').write(code)
#print code

rv = compile(code, 'test', 'exec')
eval(rv)

from pyxb.exceptions_ import *

import unittest

class TestTrac_0088 (unittest.TestCase):
    def test (self):
        enums = tEnum._CF_enumeration.items()
        self.assertEqual(3, len(enums))
        self.assertEqual(enums[0].tag(), 'emptyString')
        self.assertEqual(enums[0].value(), u'\xb0')
        self.assertEqual(enums[1].tag(), 'm')
        self.assertEqual(enums[1].value(), u'm\xb2')
        self.assertEqual(enums[2].tag(), 'm_')
        self.assertEqual(enums[2].value(), u'm\xb3')

if __name__ == '__main__':
    unittest.main()

@@ -495,28 +495,24 @@
 ue=%22
-%25s%22/%3E 
+%C2%B0%22/
 %3E %3C!-- 
-u'%5Cxb0'
+degree
  --%3E
@@ -552,37 +552,53 @@
 eration value=%22m
-%25s
+%C2%B2
 %22/%3E
+ %3C!-- squared --%3E
 %0A               
@@ -634,12 +634,26 @@
 e=%22m
-%25s%22/
+%C2%B3%22/%3E %3C!-- cubed --
 %3E%0A  
@@ -726,41 +726,11 @@
 ma%3E%0A
+
 '''
- %25 (u'%5Cxb0', u'%5Cxb2', u'%5Cxb3')
 %0A%0A#o
@@ -1218,12 +1218,9 @@
 , u'
-%5Cxb0
+%C2%B0
 ')%0A 
@@ -1314,12 +1314,9 @@
  u'm
-%5Cxb2
+%C2%B2
 ')%0A 
@@ -1411,12 +1411,9 @@
  u'm
-%5Cxb3
+%C2%B3
 ')%0A%0A

use utf-8 encoding for schema