Inspectopedia 2025.2 Help

File contains non-ASCII character

Reports cases in Python 2 when a file contains non-ASCII characters and does not have an encoding declaration at the top.

Example:

class A(object): # №5 def __init__(self): pass

In this example, the IDE reports a non-ASCII symbol in a comment and a lack of encoding declaration. Apply the proposed quick-fix to add a missing encoding declaration:

# coding=utf-8 class A(object) # №5 def __init__(self): pass

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

PyNonAsciiChar
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Python

Inspection ID: PyNonAsciiCharInspection

Inspection options

Here you can find the description of settings available for the File contains non-ASCII character inspection, and the reference of their default values.

Select default encoding

Option ID:

myDefaultEncoding

Default value:

utf-8

Other available settings:

  • ascii

  • big5

  • big5hkscs

  • cp037

  • cp424

  • cp437

  • cp500

  • cp720

  • cp737

  • cp775

  • cp850

  • cp852

  • cp855

  • cp856

  • cp857

  • cp858

  • cp860

  • cp861

  • cp862

  • cp863

  • cp864

  • cp865

  • cp866

  • cp869

  • cp874

  • cp875

  • cp932

  • cp949

  • cp950

  • cp1006

  • cp1026

  • cp1140

  • cp1250

  • cp1251

  • cp1252

  • cp1253

  • cp1254

  • cp1255

  • cp1256

  • cp1257

  • cp1258

  • euc-jp

  • euc-jis-2004

  • euc-kr

  • gb2312

  • gbk

  • gb18030

  • hz

  • iso2022-jp

  • iso2022-jp-1

  • iso2022-jp-2

  • iso2022-jp-2004

  • iso2022-jp-3

  • iso2022-jp-ext

  • iso2022-kr

  • latin-1

  • iso8859-2

  • iso8859-3

  • iso8859-4

  • iso8859-5

  • iso8859-6

  • iso8859-7

  • iso8859-8

  • iso8859-9

  • iso8859-10

  • iso8859-13

  • iso8859-14

  • iso8859-15

  • iso8859-16

  • johab

  • koi8-r

  • koi8-u

  • mac-cyrillic

  • mac-greek

  • mac-iceland

  • mac-latin2

  • mac-roman

  • mac-turkish

  • ptcp154

  • shift-jis

  • shift-jis-2004

  • shift-jisx0213

  • utf-32

  • utf-32-be

  • utf-32-le

  • utf-16

  • utf-16-be

  • utf-16-le

  • utf-7

  • utf-8-sig

Encoding comment format

Option ID:

myEncodingFormatIndex

Default value:

# coding=<encoding name>

Other available settings:

  • # -*- coding: <encoding name> -*-

  • # vim: set fileencoding=<encoding name>

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection PyNonAsciiChar

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Last modified: 18 September 2025