Source: https://mokxi.com/errors/stray-in-program
Updated: 2026-11-16

Home / Errors
Arduino build error

# error: stray '\342' in program

The code holds a character that is not plain text: a curly quote, a long dash, or a non-breaking space. C++ only reads straight quotes and ordinary spaces.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes
- Seen 2,761 times in failed builds on Mokxi in the 30 days to November 16, 2026.

The message

## What the Arduino IDE prints

Output window

The numbers in the message are the bytes of that character. They almost always come from code copied from a web page, a document or a chat.

Mokxi's compiler, clang, words it as a character that is not allowed, with its Unicode number, for example U+201C for a curly quote.

Causes

## The 2 usual causes with the fix

### 1Curly quotes around a string

Word processors and web pages turn straight quotes into curly ones. Retype both quotes in the editor.

Broken

Fixed

Mokxi’s build tab says: A character here was pasted from a web page or a document

Try this fix in Mokxi

### 2A long dash instead of a minus

An en dash or em dash looks like a minus sign and is a different character. Type a plain hyphen.

Broken

Fixed

Try this fix in Mokxi

FAQ

## Questions and answers

### What does "stray '\342' in program" mean?

The sketch contains a character the compiler cannot read. The three numbers \342 \200 \234 together are one curly quote.

### Why do I only see it after pasting code?

Web pages and documents swap plain characters for typographic ones. Retype the quotes and dashes in the editor.

### Does the \302 version mean the same thing?

Yes. \302 starts a non-breaking space. Delete the space and type it again.

Next

## More errors and the longer guide

- error: expected primary-expression before ')' token
- error: expected ';' before '}' token

The longer guide to this error All Arduino errors
