SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
Expand all | Collapse all

HOST command encoding issues on SPSS 29.0.2.0 (20)

  • 1.  HOST command encoding issues on SPSS 29.0.2.0 (20)

    Posted Thu December 05, 2024 06:02 AM
    Edited by Soren V. Raben Thu December 05, 2024 06:34 AM

    I have serious problems with HOST command. It seems that it doesn't recognize local characters properly. I wrote a piece of syntax to move files from one location to another. No matter encoding setting (chcp 65001 or chcp 1250), I always get 001 code, even though I work with SPSS in Unicode mode only. 

    Fail 1 - no encoding specified:

    host command = [
    'move "C:\pąth_with_łóćął_ćhąrąćtęrś\fiłę.xlsx" "C:\Desktop\fiłę.xlsx"'
    ].

    Fail 2 - local encoding specified:

    host command = [
      'chcp 1250'
    'move "C:\pąth_with_łóćął_ćhąrąćtęrś\fiłę.xlsx" "C:\Desktop\fiłę.xlsx"'
    ].

    Fail 3 - UTF-8 encoding specified:

    host command = [
    'chcp 65001'
    'move "C:\pąth_with_łóćął_ćhąrąćtęrś\fiłę.xlsx" "C:\Desktop\fiłę.xlsx"'
    ].

    Error message:

    The HOST command 'CD /d C:\PROGRA~1\IBM\SPSS\STATIS~1\29 && move "C:\pąth_with_łóćął_ćhąrąćtęrś\fiłę.xlsx" "C:\Desktop\fiłę.xlsx"' terminated with exit status 001.

    Does HOST command not work anymore with local characters?

    EDIT: the temporary and unconvenient solution is to globally change Windows region settings to UTF-8 for all languages. Still, even Windows warns this is a beta option, not to mention that each change there requires restart and it affects many other areas of daily usage (e.g. reading previously locally encoded Excel files).



  • 2.  RE: HOST command encoding issues on SPSS 29.0.2.0 (20)

    Posted Thu December 05, 2024 09:30 AM
    Edited by Jon Peck Thu December 05, 2024 01:22 PM
    As far as I know, the HOSt command just passes text as is to the Windows command/shell process without any encoding changes.  So, if SPSS is in Unicode mode, it would probably just pass the text as utf-8 characters or, maybe, since the SPSS frontend uses straight Unicode, it might be unencoded Unicode characters.
    Try running a DOS echo command with extended characters and see what you get.
    I should also point out that your chcp command is a DOS/Windows command, not an SPSS command, and all the text of the HOST command would already have been submitted to the Windows command processor.  SPSS would not have done anything with it other than send it on to Windows.
    Another thing to consider with the stream of long commands from SPSS, you might consider creating bat file with the long command stream and just executing it, perhaps with parameters, using the HOST command. 
    --