You mentioned previously that you are getting multiple encoding lines at the top of your syntax file? That seems odd! This syntax occurs only once in each syntax file: * Encoding: UTF-8.
Original Message:
Sent: Tue April 29, 2025 03:28 PM
From: David Dwyer
Subject: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
Hi @Chris Keran,
Assumptions I'm making about your scenario:
- You have IBM SPSS Statistics 30.0.0.0 (172) installed. If you are connecting to an IBM SPSS Statistics Server, then that too should be version 30.0.0.0 (172). Check your version with "SHOW VERSION." command syntax.
- Statistics is running in Unicode mode with the Locale set to the same as your Windows display language. Check this with "SHOW UNICODE LOCALE." command syntax.
- Your command syntax file is also in Unicode with all characters appropriate for your chosen LOCALE
You mentioned previously that you are getting multiple encoding lines at the top of your syntax file? That seems odd!
Ideally, I would have you open a Support case and we could dig into your environment and this (these?) syntax file(s) more thoroughly.
------------------------------
David Dwyer
Global Solution Consultant
IBM
Original Message:
Sent: Tue April 29, 2025 01:10 PM
From: Chris Keran
Subject: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
This is at the very top of the syntax file: * Encoding: UTF-8.
The rest is just SPSS syntax/comments.
FYI, still have that copy/paste issue between SPSS and anything else, so I took me a bit to paste the encoding text. :)
------------------------------
Chris Keran
Original Message:
Sent: Tue April 29, 2025 01:01 PM
From: Jon Peck
Subject: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
Hmm, Does the file have a BOM (byte order mark) at the start
Original Message:
Sent: 4/29/2025 12:56:00 PM
From: Chris Keran
Subject: RE: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
Thanks for the suggestion, Jon, unfortunately that didn't work.
FYI, here is the syntax I just tried that didn't work to prevent the warning (the warning appears only in the syntax window NOT the Output window).
SET UNICODE ON.
INSERT FILE='K:\CEA\MI\RESOURCES\SPSS\World Regions syntax.sps' ENCODING='UTF8'.
Fyi, I tried with/without the ENCODING='UTF8.
------------------------------
************
Chris Keran
************
Original Message:
Sent: Tue April 29, 2025 12:49 PM
From: Jon Peck
Subject: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
There were some circumstances where an external invocation of SPSS would not start in Unicode mode. I don't know whether that is still true, but try running a SET UNICODE ON command before the INSERT. You can't put the SET command in the INSERT file as it reads the file before executing the contents IIRC.
Original Message:
Sent: 4/29/2025 12:44:00 PM
From: Chris Keran
Subject: RE: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
Hi @David Dwyer,
I receive a similar warning message when I try to run an INSERT command "SPSS Statistics read a line of syntax which contains one or more characters which are invalid in the current locale. These characters have been converted to question marks." When I open the syntax file and simply run all I do not get this warning, so I assume it is related to the INSERT command.
I am using IBM SPSS Statistics 30.0.0.0 (build 172) on a Windows 11 machine and both my syntax windows (parent/child, where child is in the INSERT command) have "* Encoding: UTF-8." at the very top line of the syntax file. I also ran SHOW LOCALE and the results show "en_US.windows-1252 (English)".
Any thoughts?
------------------------------
Chris Keran
Original Message:
Sent: Wed November 13, 2024 02:59 PM
From: David Dwyer
Subject: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
Hi @Kevin Taylor
A couple things:
- For some time now IBM SPSS Statistics has defaulted to Unicode mode. Note that it is possible to have SPSS Statistics set for Unicode mode, but have an SPSS Statistics Syntax Editor document in Codepage mode. This can lead to confusion and failed runs. My suggestion is to put your SPSS Statistics into Unicode mode and never look back. You can change the underlying SPSS Locale to fit whatever character set you'd like to use. But for most (all) occasions you will want to stay in Unicode mode.
- The very first release of IBM SPSS Statistics 30.0.0.0 (build 171) showed the behavior you are describing in the syntax editor. This release was refreshed with IBM SPSS Statistics 30.0.0.0 (build 172). Be sure that your instance of Statistics 30.0.0.0 is build 172. If it is not, please download the media once more. The Part number is on the Download Document for 30.0.

------------------------------
David Dwyer
SPSS Technical Support
IBM Software
Original Message:
Sent: Tue November 12, 2024 11:36 AM
From: Kevin Taylor
Subject: Frequently Get :This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results
When I am writing code in the SPSS syntax editor, I frequently get a Failed to save document box when I select the save icon. If I try to save again, I get a box with the following:
This file contains one or more characters not recognized by the selected or default encoding. The syntax could produce errors or could produce unintended results.
Press OK to continue. Press Cancel to select a different encoding.
When I select OK, the file saves, but frequently the cursor disappears from the syntax window and nothing works. I can work with the data and output windows but sometimes they are a problem as well.
I notice that I get multiple *Encoding: at the top of the file. Sometimes the top line is: * Encoding: UTF-8.
I am using version 30, but this started happening with the previous version. I have been using SPSS for years and have not seen this before. It really puts a hit on productivity, and I can't seem to find an answer.
Any help would be really appreciated.
------------------------------
Kevin Taylor
------------------------------