STAX V3.5.0 uses Jython 2.5.2 (based on Python 2.5).

Try:

     <script>
    mystring = unicode('Störung.am.Netz', 'utf-8') 
    print mystring.encode('utf8')
  </script>

  <log message="True">mystring.encode('utf8')</log>

or:

     <script>
    import sys
    reload(sys)
    sys.setdefaultencoding( "latin-1" )
 
    mystring = u'Störung.am.Netz'
    print mystring
     </script>

  <log message="True">mystring</log>

Let me know if these suggestions worked for you.

See the following link for these suggestions for how to get around Python 
UnicodeEncodeErr: 'ascii' codec can't encode character. 

http://www.saltycrane.com/blog/2008/11/python-unicodeencodeerror-ascii-codec-cant-encode-character/


--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




From:   Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
To:     "'staf-users@lists.sourceforge.net'" 
<staf-users@lists.sourceforge.net>
Date:   06/20/2011 09:21 AM
Subject:        [staf-users] Print Unicode from STAX



Hi,
 
we are using STAX V3.5.0 Beta 1 and STAF 3.4.5 on a Linux x86_32.
 
Here is some more info from the server:
 
# echo $LANG
de_DE.UTF-8
# staf local VAR RESOLVE STRING {STAF/Config/CodePage}
Response
--------
UTF-8
#
 
The appended STAX-file written in UTF-8 defines a string containing a
German “Umlaut o”. When it tries to write this string to STAXMon or
Job_User_Log using Jython print or <log>,  an error is thrown (Msg from 
the Job_Log):
 
20110620-14:44:57 Error STAXPythonEvaluationError signal raised. 
Terminating job.
 
===== XML Information =====
 
File: /home/STAF/emach/testit.xml, Machine: local://local
Line 6: Error in element type "script".
 
===== Python Error Information =====
 
com.ibm.staf.service.stax.STAXPythonEvaluationException:
Traceback (most recent call last):
  File "<pyExec string>", line 5, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in 
position 4: ordinal not in range(128)
 
===== Call Stack for STAX Thread 1 =====
 
[]
 
 
Then I inserted
            # -*- coding: utf-8 -*-
as the first line of the first <script>. That results in an error when 
starting the script (note: in this message the
“Umlaut o” is displayed correctly on the screen): 
 
            Error submitting request, RC: 4001
Additional info
---------------
Job ID       : 50
Error Message: Caught 
com.ibm.staf.service.stax.STAXPythonCompileException:
File: /home/STAF/emach/testit.xml, Machine: local://local
Line 6: Error in element type "script".
 
Python code compile failed for:
# -*- coding: utf-8 -*-
 
print "Let's start the test\n"
 
mystring = u"Störung.am.Netz"
 
print "1 " + mystring + '\n'
 
 
 
SyntaxError: Illegal character in file '<string>' for encoding 'utf-8'
 
 
 
 
Is there a way to use UTF-8 in STAX consistently? Am I doing something 
wrong?
 
Thanx in advance
Bodo
 [attachment "testit.xml" deleted by Sharon Lucas/Austin/IBM] 
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to