Articles
Published · November 18, 2026

Mixed Chinese and English Text Files: Encoding and Line Breaks Done Right

Greeting lists, notes and READMEs that mix Chinese and English break when the encoding or line endings are wrong. Save as UTF-8, skip the BOM, use LF.

Also in: Español中文हिन्दी

Quick answer

Save a mixed Chinese and English file as UTF-8, without a byte order mark, with LF line endings. That combination opens correctly almost everywhere, keeps English text readable to older tools, and behaves well in Git. When Chinese text turns into odd symbols, the file isn't broken. It was saved in one encoding and read as another.

How it actually works

One encoding for both scripts

UTF-8 stores every ASCII character, meaning each English letter, digit and space, in a single byte, and it can represent Chinese characters too. That is why one UTF-8 file can hold a greeting in Chinese followed by an English translation with no switching.

China's national standard, GB 18030, also covers all of Unicode. It uses one byte for ASCII, two bytes for extended GBK, or four bytes, and it is built as an extension of GBK. You'll mostly meet it in older files and in software made for the Chinese market. For files you create today and share across devices, UTF-8 is the safer default.

The BOM question

A byte order mark is the character U+FEFF placed at the start of a file. In UTF-8 it is the three bytes EF BB BF. According to the Wikipedia article on the byte order mark, the Unicode Standard permits it in UTF-8 but does not require or recommend it. A BOM is also not needed to detect UTF-8, because invalid byte sequences rule UTF-8 out.

The catch: a BOM can interfere with software that does not expect non-ASCII bytes at the start of a file. Some Windows software went the other way: Notepad, before Windows 10 build 1903, treated the BOM as a required marker. The rule is simple. Leave the BOM off, and add one only when a specific tool refuses to recognize your UTF-8 without it.

Legacy files and garbled characters

If a Chinese file opens as nonsense, it is probably a legacy GBK or GB 18030 file read as UTF-8. The reverse also happens. Opening a GB 18030 file as GBK can fail or corrupt text when the file contains characters GBK does not have. Our guide to how to diagnose garbled characters covers the full process. On a Mac, two standard commands cover the common case:

file -I notes.txt                          # report the detected encoding
iconv -f GB18030 -t UTF-8 notes.txt > notes-utf8.txt

Check the converted copy before you delete the original.

Line breaks: hard breaks, soft wraps and CJK

Hard breaks

A hard break is a character in the file. Under the Unicode line breaking rules, CR, LF and NEL each force a break, and a CR followed by LF counts as a single break. Windows files typically use CRLF, while macOS and Linux use LF. Mixed endings inside one file are the real trouble, since tools disagree about what a "line" is. See CRLF vs LF for the details.

If the file lives in a repository, let Git normalize it. The gitattributes documentation recommends a rule like this, which stores LF in the repository and lets each machine check out its preferred style:

* text=auto

Soft wrapping

A soft wrap is where the editor folds a long line to fit the screen, and it follows different rules for each script. The same Unicode rules say ideographs allow a break before or after them, while alphabetic words rely on spaces. So a Chinese sentence can wrap between any two characters, and an English phrase inside it wraps at its spaces.

Punctuation has constraints. Closing punctuation, including the ideographic full stop and comma, may not start a line, and opening punctuation may not end one. This is why you should not hard-wrap Chinese paragraphs at a fixed column. A manual break in the middle of a sentence stays put when the window changes size, leaving a stray break in the text. Keep one paragraph per line and let the editor wrap it. If you must stop a break at a specific point, U+2060 WORD JOINER prevents one around an ideograph.

When to use it (and when to skip it)

Use UTF-8 for anything you write, share or keep in version control. It handles a mixed greeting list, a bilingual README and a notes folder alike. For punctuation, spacing and font choices inside Markdown, see Chinese punctuation, spacing and fonts in Markdown.

Skip the conversion only when a system explicitly requires GB 18030, which is mandatory in part for software sold in China. In that case, keep the original file, convert a copy, and test the round trip with a few unusual characters before you rely on it. Git's working-tree-encoding attribute can re-encode a file for you, but the documentation warns that conversion to non-UTF encodings may not round-trip safely and recommends it only when you cannot store the file as UTF-8.

How Carets fits in

Mixed-language files are plain text, and plain text is what Carets is built for. Carets is a native notes and code editor for iPhone, iPad and Mac, so your Chinese and English notes, Markdown drafts and config files all open in one place. Because your files stay plain text, they stay portable: you can move the same file into Git, a shared folder or another editor without a conversion step. Files, projects and tags keep a folder of bilingual notes organized, and syntax highlighting helps when the file is code with Chinese comments.

Get Carets on the App Store for iPhone, iPad and Mac.

Frequently Asked Questions

Should a Chinese text file be UTF-8 with or without a BOM?

Without, by default. The Unicode Standard permits a UTF-8 BOM but does not require or recommend it, and it can trip up software that does not expect non-ASCII bytes at the start of a file. Add one only when a specific Windows tool needs it to recognize UTF-8.

Why does my Chinese text turn into odd symbols?

The file was saved in one encoding and read as another, typically a legacy GBK or GB 18030 file opened as UTF-8. Re-open it with the original encoding, then save it as UTF-8.

Does Chinese text need spaces to wrap onto the next line?

No. Under the Unicode line breaking rules, ideographs allow a break before or after, while Latin words wrap at spaces. Closing punctuation such as the ideographic full stop will not start a line.

Which line ending should a mixed-language file use?

LF is the usual choice for files in Git. Git can normalize line endings to LF in the repository with a text=auto rule, so teammates on different systems can each keep their preferred style.