python umlauts problem

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

python umlauts problem

Mario Giesel
* Hello, SPSS friends,
  I'm writing automatically constructed syntax into a syntax window which works fine;
However, I have problems with umlauts see example below;
I also tried
# -*- coding: utf-8 -*-
but to no avail;
any ideas?.

BEGIN PROGRAM PYTHON.
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
syntax = '''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
'''
# write syntax into new syntax window
import SpssClient
SpssClient.StartClient()
NewSyntaxDoc = SpssClient.NewSyntaxDoc()
NewSyntaxDoc.SetSyntax(syntax)
NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
SpssClient.StopClient()
END PROGRAM.

* Result:
/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
.

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Mario Giesel
Munich, Germany
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Andy W
FYI this code works for me (V22 on Windows) and the umlauts are written correctly in the new syntax window.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Mario Giesel
Thanks for your comment, Andy!
  I also use V22 on Windows (Server version).
So it's probably no version issue.

  Mario


Andy W <[hidden email]> schrieb am 17:26 Dienstag, 23.September 2014:


FYI this code works for me (V22 on Windows) and the umlauts are written
correctly in the new syntax window.



-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/python-umlauts-problem-tp5727361p5727362.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD



===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Mario Giesel
Munich, Germany
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Mario Giesel
In reply to this post by Mario Giesel
* 1.
DATA LIST /country 1-1 gender 2-2.
BEGIN DATA
12
21
END DATA.
VALUE LABELS country 1 'Dänemark' 2 'Österreich'.
VALUE LABELS gender 1 'Männlich' 2 'Weiblich'.
CTABLES /TABLE gender by country /* umlauts are shown correctly, also with FREQUENCIES */.
=>
        country   
        Dänemark    Österreich
        Anzahl    Anzahl
gender    Männlich    0    1
    Weiblich    1    0

* 2.
SHOW UNICODE /* result is Yes */.
=>
Systemeinstellungen       
Schlüsselwort    Beschreibung    Einstellung
UNICODE    Angabe, ob der Prozessor im Unicodemodus betrieben wird    Ja

* 3.
SHOW LOCALE.
=>
Systemeinstellungen       
Schlüsselwort    Beschreibung    Einstellung
LOCALE    Land und Zeichensatz    de_DE.windows-1252 (de_DE)

Hope that helps, Jon. I'm in a two days vacation now.

Thanks, Mario



Jon K Peck <[hidden email]> schrieb am 16:01 Mittwoch, 24.September 2014:


You can see the current setting via Edit >Options.  In V22 it is on the Language tab.  You can also run SHOW UNICODE, which might be better for Server.

Since there are no umlaut characters in the Python code, I expect that you would get the same behavior just running the Frequencies command directly.  Is that what happens?

If you want to send me the file, I can try this out.  Let me know also what the output is for SHOW LOCALE.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Mario Giesel <[hidden email]>
To:        Jon K Peck/Chicago/IBM@IBMUS
Date:        09/24/2014 07:47 AM
Subject:        Re: [SPSSX-L] python umlauts problem




Thanks, Jon, I don't know how to check for UNICODE mode.
I use normal SPSS 22 on Windows server without changing a mode.
Meanwhile I found out that all German umlauts are affected:

/* Ä / Ö / Ü / ä / ö / ü / ß */
become
/* Ä / Ö / Ü / ä ö ü ß */



  Mario


Jon K Peck <[hidden email]> schrieb am 23:17 Dienstag, 23.September 2014:


This might be a different problem from the one I sent mail about earlier.  Are you in Unicode mode?  The mangled character looks like the utf-8 byte sequence for the umlauted character.  I am traveling at the moment and can't check further, but the umlaut hotfix would still be a good idea.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621





From:        
Mario Giesel <[hidden email]>
To:        
[hidden email]
Date:        
09/23/2014 10:02 AM
Subject:        
[SPSSX-L] python umlauts problem
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




* Hello, SPSS friends,
I'm writing automatically constructed syntax into a syntax window which works fine;
However, I have problems with umlauts see example below;
I also tried
# -*- coding: utf-8 -*-
but to no avail;
any ideas?.

BEGIN PROGRAM PYTHON.
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
syntax = '''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
'''
# write syntax into new syntax window
import SpssClient
SpssClient.StartClient()
NewSyntaxDoc = SpssClient.NewSyntaxDoc()
NewSyntaxDoc.SetSyntax(syntax)
NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
SpssClient.StopClient()
END PROGRAM.

* Result:
/* Österreich (use German 'Oe')*/
FREQUENCIES q01.


.


===================== To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD





===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Mario Giesel
Munich, Germany
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Jon K Peck
I see the problem.  The following version works.  For a literal constant, as here, you could also just use
syntax = u'''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
'''
If the text in question is a variable, then the unicode function would be needed.



BEGIN PROGRAM PYTHON.
#!/usr/bin/env python
syntax = unicode('''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
''')
# write syntax into new syntax window
import SpssClient
SpssClient.StartClient()
NewSyntaxDoc = SpssClient.NewSyntaxDoc()
NewSyntaxDoc.SetSyntax(syntax)
NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
SpssClient.StopClient()
END PROGRAM.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Mario Giesel <[hidden email]>
To:        [hidden email]
Date:        09/24/2014 09:33 AM
Subject:        Re: [SPSSX-L] python umlauts problem
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




* 1.
DATA LIST /country 1-1 gender 2-2.
BEGIN DATA
12
21
END DATA.
VALUE LABELS country 1 'Dänemark' 2 'Österreich'.
VALUE LABELS gender 1 'Männlich' 2 'Weiblich'.
CTABLES /TABLE gender by country /* umlauts are shown correctly, also with FREQUENCIES */.
=>
       country    
       Dänemark    Österreich
       Anzahl    Anzahl
gender    Männlich    0    1
   Weiblich    1    0

* 2.
SHOW UNICODE /* result is Yes */.
=>
Systemeinstellungen        
Schlüsselwort    Beschreibung    Einstellung
UNICODE    Angabe, ob der Prozessor im Unicodemodus betrieben wird    Ja

* 3.
SHOW LOCALE.
=>
Systemeinstellungen        
Schlüsselwort    Beschreibung    Einstellung
LOCALE    Land und Zeichensatz    de_DE.windows-1252 (de_DE)


Hope that helps, Jon. I'm in a two days vacation now.

Thanks, Mario



Jon K Peck <[hidden email]> schrieb am 16:01 Mittwoch, 24.September 2014:


You can see the current setting via Edit >Options.  In V22 it is on the Language tab.  You can also run SHOW UNICODE, which might be better for Server.

Since there are no umlaut characters in the Python code, I expect that you would get the same behavior just running the Frequencies command directly.  Is that what happens?


If you want to send me the file, I can try this out.  Let me know also what the output is for SHOW LOCALE.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621





From:        
Mario Giesel <[hidden email]>
To:        
Jon K Peck/Chicago/IBM@IBMUS
Date:        
09/24/2014 07:47 AM
Subject:        
Re: [SPSSX-L] python umlauts problem




Thanks, Jon, I don't know how to check for UNICODE mode.

I use normal SPSS 22 on Windows server without changing a mode.

Meanwhile I found out that all German umlauts are affected:


/* Ä / Ö / Ü / ä / ö / ü / ß */
become
/* Ä / Ö / Ü / ä ö ü ß */



 Mario



Jon K Peck <[hidden email]> schrieb am 23:17 Dienstag, 23.September 2014:



This might be a different problem from the one I sent mail about earlier.  Are you in Unicode mode?  The mangled character looks like the utf-8 byte sequence for the umlauted character.  I am traveling at the moment and can't check further, but the umlaut hotfix would still be a good idea.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621





From:        
Mario Giesel <[hidden email]>
To:        
[hidden email]
Date:        
09/23/2014 10:02 AM
Subject:        
[SPSSX-L] python umlauts problem
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




* Hello, SPSS friends,
I'm writing automatically constructed syntax into a syntax window which works fine;
However, I have problems with umlauts see example below;
I also tried
# -*- coding: utf-8 -*-
but to no avail;
any ideas?.

BEGIN PROGRAM PYTHON.
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
syntax = '''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
'''
# write syntax into new syntax window
import SpssClient
SpssClient.StartClient()
NewSyntaxDoc = SpssClient.NewSyntaxDoc()
NewSyntaxDoc.SetSyntax(syntax)
NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
SpssClient.StopClient()
END PROGRAM.

* Result:
/* Österreich (use German 'Oe')*/
FREQUENCIES q01.


.


===================== To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD





===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Mario Giesel
Thanks Jon!

Unicoding the string with u'''...''' works perfectly well.
The function unicode('''...'''), however, did not produce a correct result.

Thanks, again,
  Mario


Jon K Peck <[hidden email]> schrieb am 19:16 Mittwoch, 24.September 2014:


I see the problem.  The following version works.  For a literal constant, as here, you could also just use
syntax = u'''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
'''
If the text in question is a variable, then the unicode function would be needed.



BEGIN PROGRAM PYTHON.
#!/usr/bin/env python
syntax = unicode('''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
''')
# write syntax into new syntax window
import SpssClient
SpssClient.StartClient()
NewSyntaxDoc = SpssClient.NewSyntaxDoc()
NewSyntaxDoc.SetSyntax(syntax)
NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
SpssClient.StopClient()
END PROGRAM.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Mario Giesel <[hidden email]>
To:        [hidden email]
Date:        09/24/2014 09:33 AM
Subject:        Re: [SPSSX-L] python umlauts problem
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




* 1.
DATA LIST /country 1-1 gender 2-2.
BEGIN DATA
12
21
END DATA.
VALUE LABELS country 1 'Dänemark' 2 'Österreich'.
VALUE LABELS gender 1 'Männlich' 2 'Weiblich'.
CTABLES /TABLE gender by country /* umlauts are shown correctly, also with FREQUENCIES */.
=>
       country    
       Dänemark    Österreich
       Anzahl    Anzahl
gender    Männlich    0    1
   Weiblich    1    0

* 2.
SHOW UNICODE /* result is Yes */.
=>
Systemeinstellungen        
Schlüsselwort    Beschreibung    Einstellung
UNICODE    Angabe, ob der Prozessor im Unicodemodus betrieben wird    Ja

* 3.
SHOW LOCALE.
=>
Systemeinstellungen        
Schlüsselwort    Beschreibung    Einstellung
LOCALE    Land und Zeichensatz    de_DE.windows-1252 (de_DE)


Hope that helps, Jon. I'm in a two days vacation now.

Thanks, Mario



Jon K Peck <[hidden email]> schrieb am 16:01 Mittwoch, 24.September 2014:


You can see the current setting via Edit >Options.  In V22 it is on the Language tab.  You can also run SHOW UNICODE, which might be better for Server.

Since there are no umlaut characters in the Python code, I expect that you would get the same behavior just running the Frequencies command directly.  Is that what happens?


If you want to send me the file, I can try this out.  Let me know also what the output is for SHOW LOCALE.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621





From:        
Mario Giesel <[hidden email]>
To:        
Jon K Peck/Chicago/IBM@IBMUS
Date:        
09/24/2014 07:47 AM
Subject:        
Re: [SPSSX-L] python umlauts problem




Thanks, Jon, I don't know how to check for UNICODE mode.

I use normal SPSS 22 on Windows server without changing a mode.

Meanwhile I found out that all German umlauts are affected:


/* Ä / Ö / Ü / ä / ö / ü / ß */
become
/* Ä / Ö / Ü / ä ö ü ß */



 Mario



Jon K Peck <[hidden email]> schrieb am 23:17 Dienstag, 23.September 2014:



This might be a different problem from the one I sent mail about earlier.  Are you in Unicode mode?  The mangled character looks like the utf-8 byte sequence for the umlauted character.  I am traveling at the moment and can't check further, but the umlaut hotfix would still be a good idea.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621





From:        
Mario Giesel <[hidden email]>
To:        
[hidden email]
Date:        
09/23/2014 10:02 AM
Subject:        
[SPSSX-L] python umlauts problem
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




* Hello, SPSS friends,
I'm writing automatically constructed syntax into a syntax window which works fine;
However, I have problems with umlauts see example below;
I also tried
# -*- coding: utf-8 -*-
but to no avail;
any ideas?.

BEGIN PROGRAM PYTHON.
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
syntax = '''/* Österreich (use German 'Oe')*/
FREQUENCIES q01.
'''
# write syntax into new syntax window
import SpssClient
SpssClient.StartClient()
NewSyntaxDoc = SpssClient.NewSyntaxDoc()
NewSyntaxDoc.SetSyntax(syntax)
NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
SpssClient.StopClient()
END PROGRAM.

* Result:
/* Österreich (use German 'Oe')*/
FREQUENCIES q01.


.


===================== To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD





===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Mario Giesel
Munich, Germany
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Albert-Jan Roskam-2
In reply to this post by Mario Giesel

You have to tell unicode() which encoding to use, else sys.getdefaultencoding() is used (ascii).



------------------------------
On Mon, Sep 29, 2014 1:18 PM CEST Mario Giesel wrote:

>Thanks Jon!
>
>Unicoding the string with u'''...''' works perfectly well.
>The function unicode('''...'''), however, did not produce a correct result.
>
>Thanks, again,
>  Mario
>
>
>
>Jon K Peck <[hidden email]> schrieb am 19:16 Mittwoch, 24.September 2014:
>
>
>
>I see the problem.  The following
>version works.  For a literal constant, as here, you could also just
>use
>syntax = u'''/* Österreich (use German
>'Oe')*/
>FREQUENCIES q01.
>'''
>If the text in question is a variable,
>then the unicode function would be needed.
>
>
>
>BEGIN PROGRAM PYTHON.
>#!/usr/bin/env python
>syntax = unicode('''/* Österreich (use
>German 'Oe')*/
>FREQUENCIES q01.
>''')
># write syntax into new syntax window
>import SpssClient
>SpssClient.StartClient()
>NewSyntaxDoc = SpssClient.NewSyntaxDoc()
>NewSyntaxDoc.SetSyntax(syntax)
>NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
>SpssClient.StopClient()
>END PROGRAM.
>
>
>Jon Peck (no "h") aka Kim
>Senior Software Engineer, IBM
>[hidden email]
>phone: 720-342-5621
>
>
>
>
>From:      
> Mario Giesel <[hidden email]>
>To:      
> [hidden email]
>Date:      
> 09/24/2014 09:33 AM
>Subject:    
>   Re: [SPSSX-L]
>python umlauts problem
>Sent by:    
>   "SPSSX(r)
>Discussion" <[hidden email]>
>________________________________
>
>
>
>* 1.
>DATA LIST /country 1-1 gender 2-2.
>BEGIN DATA
>12
>21
>END DATA.
>VALUE LABELS country 1 'Dänemark' 2 'Österreich'.
>VALUE LABELS gender 1 'Männlich' 2 'Weiblich'.
>CTABLES /TABLE gender by country /* umlauts are shown correctly, also with
>FREQUENCIES */.
>=>
>       country    
>       Dänemark    Österreich
>       Anzahl    Anzahl
>gender    Männlich    0    1
>   Weiblich    1    0
>
>* 2.
>SHOW UNICODE /* result is Yes */.
>=>
>Systemeinstellungen        
>Schlüsselwort    Beschreibung    Einstellung
>UNICODE    Angabe, ob der Prozessor im Unicodemodus betrieben
>wird    Ja
>
>* 3.
>SHOW LOCALE.
>=>
>Systemeinstellungen        
>Schlüsselwort    Beschreibung    Einstellung
>LOCALE    Land und Zeichensatz    de_DE.windows-1252
>(de_DE)
>
>Hope that helps, Jon. I'm in a two days
>vacation now.
>
>Thanks, Mario
>
>
>
>Jon K Peck <[hidden email]> schrieb
>am 16:01 Mittwoch, 24.September 2014:
>
>
>You can see the current setting via
>Edit >Options.  In V22 it is on the Language tab.  You can
>also run SHOW UNICODE, which might be better for Server.
>
>Since there are no umlaut characters in the Python code, I expect that
>you would get the same behavior just running the Frequencies command directly.
> Is that what happens?
>
>If you want to send me the file, I can try this out.  Let me know
>also what the output is for SHOW LOCALE.
>
>
>Jon Peck (no "h") aka Kim
>Senior Software Engineer, IBM
>[hidden email]
>phone: 720-342-5621
>
>
>
>
>From:        Mario
>Giesel <[hidden email]>
>To:        Jon
>K Peck/Chicago/IBM@IBMUS
>Date:        09/24/2014
>07:47 AM
>Subject:        Re:
>[SPSSX-L] python umlauts problem
>
>________________________________
>
>
>
>Thanks, Jon, I don't know how to check for UNICODE mode.
>I use normal SPSS 22 on Windows server without changing a mode.
>Meanwhile I found out that all German umlauts are affected:
>
>/* Ä / Ö / Ü / ä / ö / ü / ß */
>become
>/* Ä / Ö / Ü / ä ö ü ß */
>
>
> Mario
>
>
>Jon K Peck <[hidden email]> schrieb am 23:17 Dienstag, 23.September
>2014:
>
>
>This might be a different problem from the one I sent mail about earlier.
> Are you in Unicode mode?  The mangled character looks like the
>utf-8 byte sequence for the umlauted character.  I am traveling at
>the moment and can't check further, but the umlaut hotfix would still be
>a good idea.
>
>
>Jon Peck (no "h") aka Kim
>Senior Software Engineer, IBM
>[hidden email]
>phone: 720-342-5621
>
>
>
>
>From:        Mario
>Giesel <[hidden email]>
>To:        [hidden email]
>Date:        09/23/2014
>10:02 AM
>Subject:        [SPSSX-L]
>python umlauts problem
>Sent by:        "SPSSX(r)
>Discussion" <[hidden email]>
>
>________________________________
>
>
>
>* Hello, SPSS friends,
>I'm writing automatically constructed syntax into a syntax window which
>works fine;
>However, I have problems with umlauts see example below;
>I also tried
># -*- coding: utf-8 -*-
>but to no avail;
>any ideas?.
>
>BEGIN PROGRAM PYTHON.
>#!/usr/bin/env python
># -*- coding: iso-8859-1 -*-
>syntax = '''/* Österreich (use German 'Oe')*/
>FREQUENCIES q01.
>'''
># write syntax into new syntax window
>import SpssClient
>SpssClient.StartClient()
>NewSyntaxDoc = SpssClient.NewSyntaxDoc()
>NewSyntaxDoc.SetSyntax(syntax)
>NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
>SpssClient.StopClient()
>END PROGRAM.
>
>* Result:
>/* Österreich (use German 'Oe')*/
>FREQUENCIES q01.
>
>.
>
>===================== To manage your subscription to SPSSX-L, send a message
>to [hidden email](not to SPSSX-L), with no body text except the command. To leave the list,
>send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions,
>send the command INFO REFCARD
>
>
>
>
>
>===================== To manage your subscription to SPSSX-L,
>send a message to [hidden email](not to SPSSX-L), with no body text except the command. To leave the list,
>send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions,
>send the command INFO REFCARD
>
>=====================
>To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the
>command. To leave the list, send the command
>SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
>INFO REFCARD
>
>=====================
>To manage your subscription to SPSSX-L, send a message to
>[hidden email] (not to SPSSX-L), with no body text except the
>command. To leave the list, send the command
>SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
>INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: python umlauts problem

Mario Giesel
Okay, Albert-Jan, good to know.
Thanks for the additional remark.

  Mario


Albert-Jan Roskam <[hidden email]> schrieb am 8:54 Dienstag, 30.September 2014:



You have to tell unicode() which encoding to use, else sys.getdefaultencoding() is used (ascii).



------------------------------
On Mon, Sep 29, 2014 1:18 PM CEST Mario Giesel wrote:

>Thanks Jon!
>
>Unicoding the string with u'''...''' works perfectly well.
>The function unicode('''...'''), however, did not produce a correct result.
>
>Thanks, again,
>  Mario
>
>
>
>Jon K Peck <[hidden email]> schrieb am 19:16 Mittwoch, 24.September 2014:
>
>
>
>I see the problem.  The following
>version works.  For a literal constant, as here, you could also just
>use
>syntax = u'''/* Österreich (use German
>'Oe')*/
>FREQUENCIES q01.
>'''
>If the text in question is a variable,
>then the unicode function would be needed.
>
>
>
>BEGIN PROGRAM PYTHON.
>#!/usr/bin/env python
>syntax = unicode('''/* Österreich (use
>German 'Oe')*/
>FREQUENCIES q01.
>''')
># write syntax into new syntax window
>import SpssClient
>SpssClient.StartClient()
>NewSyntaxDoc = SpssClient.NewSyntaxDoc()
>NewSyntaxDoc.SetSyntax(syntax)
>NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
>SpssClient.StopClient()
>END PROGRAM.
>
>
>Jon Peck (no "h") aka Kim
>Senior Software Engineer, IBM
>[hidden email]
>phone: 720-342-5621
>
>
>
>
>From:     
> Mario Giesel <[hidden email]>
>To:     
> [hidden email]
>Date:     
> 09/24/2014 09:33 AM
>Subject:   
>  Re: [SPSSX-L]
>python umlauts problem
>Sent by:   
>  "SPSSX(r)
>Discussion" <[hidden email]>
>________________________________
>
>
>
>* 1.
>DATA LIST /country 1-1 gender 2-2.
>BEGIN DATA
>12
>21
>END DATA.
>VALUE LABELS country 1 'Dänemark' 2 'Österreich'.
>VALUE LABELS gender 1 'Männlich' 2 'Weiblich'.
>CTABLES /TABLE gender by country /* umlauts are shown correctly, also with
>FREQUENCIES */.
>=>
>      country   
>      Dänemark    Österreich
>      Anzahl    Anzahl
>gender    Männlich    0    1
>  Weiblich    1    0
>
>* 2.
>SHOW UNICODE /* result is Yes */.
>=>
>Systemeinstellungen       
>Schlüsselwort    Beschreibung    Einstellung
>UNICODE    Angabe, ob der Prozessor im Unicodemodus betrieben
>wird    Ja
>
>* 3.
>SHOW LOCALE.
>=>
>Systemeinstellungen       
>Schlüsselwort    Beschreibung    Einstellung
>LOCALE    Land und Zeichensatz    de_DE.windows-1252
>(de_DE)
>
>Hope that helps, Jon. I'm in a two days
>vacation now.
>
>Thanks, Mario
>
>
>
>Jon K Peck <[hidden email]> schrieb
>am 16:01 Mittwoch, 24.September 2014:
>
>
>You can see the current setting via
>Edit >Options.  In V22 it is on the Language tab.  You can
>also run SHOW UNICODE, which might be better for Server.
>
>Since there are no umlaut characters in the Python code, I expect that
>you would get the same behavior just running the Frequencies command directly.
> Is that what happens?
>
>If you want to send me the file, I can try this out.  Let me know
>also what the output is for SHOW LOCALE.
>
>
>Jon Peck (no "h") aka Kim
>Senior Software Engineer, IBM
>[hidden email]
>phone: 720-342-5621
>
>
>
>
>From:        Mario
>Giesel <[hidden email]>
>To:        Jon
>K Peck/Chicago/[hidden email]
>Date:        09/24/2014
>07:47 AM
>Subject:        Re:
>[SPSSX-L] python umlauts problem
>
>________________________________
>
>
>
>Thanks, Jon, I don't know how to check for UNICODE mode.
>I use normal SPSS 22 on Windows server without changing a mode.
>Meanwhile I found out that all German umlauts are affected:
>
>/* Ä / Ö / Ü / ä / ö / ü / ß */
>become
>/* Ä / Ö / Ü / ä ö ü ß */
>
>
> Mario
>
>
>Jon K Peck <[hidden email]> schrieb am 23:17 Dienstag, 23.September
>2014:
>
>
>This might be a different problem from the one I sent mail about earlier.
> Are you in Unicode mode?  The mangled character looks like the
>utf-8 byte sequence for the umlauted character.  I am traveling at
>the moment and can't check further, but the umlaut hotfix would still be
>a good idea.
>
>
>Jon Peck (no "h") aka Kim
>Senior Software Engineer, IBM
>[hidden email]
>phone: 720-342-5621
>
>
>
>
>From:        Mario
>Giesel <[hidden email]>
>To:        [hidden email]
>Date:        09/23/2014
>10:02 AM
>Subject:        [SPSSX-L]
>python umlauts problem
>Sent by:        "SPSSX(r)
>Discussion" <[hidden email]>
>
>________________________________
>
>
>
>* Hello, SPSS friends,
>I'm writing automatically constructed syntax into a syntax window which
>works fine;
>However, I have problems with umlauts see example below;
>I also tried
># -*- coding: utf-8 -*-
>but to no avail;
>any ideas?.
>
>BEGIN PROGRAM PYTHON.
>#!/usr/bin/env python
># -*- coding: iso-8859-1 -*-
>syntax = '''/* Österreich (use German 'Oe')*/
>FREQUENCIES q01.
>'''
># write syntax into new syntax window
>import SpssClient
>SpssClient.StartClient()
>NewSyntaxDoc = SpssClient.NewSyntaxDoc()
>NewSyntaxDoc.SetSyntax(syntax)
>NewSyntaxDoc.SetAsDesignatedSyntaxDoc()
>SpssClient.StopClient()
>END PROGRAM.
>
>* Result:
>/* Österreich (use German 'Oe')*/
>FREQUENCIES q01.
>
>.
>
>===================== To manage your subscription to SPSSX-L, send a message
>to [hidden email](not to SPSSX-L), with no body text except the command. To leave the list,
>send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions,
>send the command INFO REFCARD
>
>
>
>
>
>===================== To manage your subscription to SPSSX-L,
>send a message to [hidden email](not to SPSSX-L), with no body text except the command. To leave the list,
>send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions,
>send the command INFO REFCARD
>
>=====================
>To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the
>command. To leave the list, send the command
>SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
>INFO REFCARD
>
>=====================
>To manage your subscription to SPSSX-L, send a message to
>[hidden email] (not to SPSSX-L), with no body text except the
>command. To leave the list, send the command
>SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
>INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Mario Giesel
Munich, Germany