Overview
react-qr-code encodes data in UTF-8 byte mode to ensure non-ASCII text (e.g., Korean, Japanese, emoji) renders and scans correctly. This means you can pass any Unicode text as a normal JavaScript string without any additional encoding required.
No additional encoding is required on your side. The library automatically handles UTF-8 conversion internally.
How It Works
The library uses theencodeStringToUtf8Bytes function to convert JavaScript strings to UTF-8 byte arrays:
src/index.js:26 when you provide a value prop. The UTF-8 bytes are then converted to a binary string and encoded in byte mode:
Usage Examples
Just pass a normal JavaScript string with any Unicode characters:Korean Text
Japanese Text
Mixed Content with Emoji
Testing Example
Testing UTF-8 Locally
To test UTF-8 encoding with the demo app:-
Build the demo library bundle in watch mode:
- In one terminal:
npm run demo-web-watch
- In one terminal:
-
Run the demo app:
- In another terminal:
npm run demo
- In another terminal:
-
Test with non-ASCII values:
- Open the demo in your browser (Expo starts it automatically)
- Type a non-ASCII value into the input:
- Korean:
안녕하세요 - Japanese:
こんにちは - Emoji: Any emoji character
- Korean:
-
Scan and verify:
- Scan the generated QR code with a phone camera app
- The decoded text should match exactly what you typed
The library uses the browser’s native
TextEncoder API, which provides reliable UTF-8 encoding across all modern browsers and React Native environments.Character Limits
According to the official QR spec, the library can store up to 2953 characters in thevalue prop. This limit applies to UTF-8 encoded data in byte mode.