# Non-ASCII characters in code

Source: https://findproxyforurl.net/rules/non-ascii-characters/ · last updated 2026-10-15

Rule PAC-E014 (`non-ascii-characters`), severity high, category: Errors and robustness.

The file contains characters outside 7-bit ASCII in code position, typically smart quotes from a word processor or a stray emoji. Smart quotes are a syntax error; other characters are at best unnecessary.

## Why it matters

Everything a PAC needs (hostnames, IP literals, proxy directives) is ASCII. Non-ASCII
characters appear through copy-paste from Word, Pages, mail clients or chat tools, which
replace `"` with U+201C/U+201D. Those are not string delimiters in JavaScript, so the file
does not parse and the client goes DIRECT. Characters inside comments are harmless to the
parser but indicate the same editing tool chain. Internationalised host names must be
written in their ASCII (punycode) form, because that is what Chrome, Edge, Firefox and Windows
(WinHTTP and WinINet) pass in `host`, in lower case: `bücher.example` and `BÜCHER.example` both
arrive as `xn--bcher-kva.example`, and `BÜCHER.Corp.Example` as `xn--bcher-kva.corp.example`
(lab, 2026-10-15). `shExpMatch(host, "*bücher*")` is therefore false in
every browser, while `shExpMatch(host, "*xn--bcher-kva*")` matches. Only `pactester` passes the
host as you type it, so a test there can match where no browser does.


## How to fix

Replace smart quotes with ASCII quotes, remove other non-ASCII characters; verify with `LC_ALL=C grep -nP '[^\x00-\x7F]' file`.

## Bad

```js
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, “.corp.example”)) {
    return “DIRECT”;
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- chromium: A non-ASCII string returned by FindProxyForURL is rejected as a script error ("returned a non-ASCII string"); non-ASCII inside string literals that are not returned is not an error. An internationalised host arrives in lower-case punycode (BÜCHER-Case.example.test as xn--bcher-case-9db.example.test), in host and in url (lab 2026-10-15, Chrome 155, Edge 155, Chromium 145; url/url_canon_host.cc DoIdnHost). (source: code, verified 2026-10-04)
- firefox: An internationalised host arrives in lower-case punycode (BÜCHER-Case.example.test as xn--bcher-case-9db.example.test), in host and in url. In the source, netwerk/base/nsPACMan.cpp takes GetAsciiHost() and GetAsciiSpec(). (source: lab, verified 2026-10-15)
- winhttp: An internationalised host arrives in lower-case punycode, in host and in url, although WinHTTP keeps the case of plain ASCII host names. The other labels of such a name are lower-cased too (BÜCHER-Case.Example.test arrives as xn--bcher-case-9db.example.test). (source: lab, verified 2026-10-15)
- wininet: An internationalised host arrives in lower-case punycode, in host and in url, also with capitals in the other labels; measured both with a direct proxy query and with real requests of a WinINet program. (source: lab, verified 2026-10-15)
