Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.7.0+

QR Code with Non-English Text (UTF-8 and ECI)

See more QR Code Examples

Demonstrates text outside ASCII. QrCode always stores text as UTF-8 bytes, which is what phones expect. A QR code can also say so explicitly with an ECI header: setting encoding.eci to 26 declares the bytes to be UTF-8, for readers that would otherwise assume another character set. The header costs a little space, and a few older readers do not understand it, so it is off by default.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  This example requires the Chilkat API to have been previously unlocked.
;  See Global Unlock Sample for sample code.

;  The text is "Gruesse aus Muenchen" written with u-umlaut and sharp s.  It is given here with
;  JSON escapes only so that this source is plain ASCII.  Decode turns the escapes into characters.
$oSbText = ObjCreate("Chilkat.StringBuilder")
$oSbText.Append("Gr\u00fc\u00dfe aus M\u00fcnchen")
$oSbText.Decode("json","utf-8")

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateSb("payload.text",$oSbText)
$oJson.UpdateString("output.path","qa_output/qr_utf8.png")
$oJson.UpdateBool("output.overwrite",True)
$oJson.UpdateString("output.return","none")

$oFmt = ObjCreate("Chilkat.Formats")
$oJsonOut = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oFmt.QrCode("generate",$oJson,$oJsonOut)
If ($bSuccess = False) Then
    ConsoleWrite($oFmt.LastErrorText & @CRLF)
    Exit
EndIf

;  17 characters, three of which take two bytes in UTF-8.
ConsoleWrite("characters: " & $oSbText.Length & @CRLF)
ConsoleWrite("bytes encoded: " & $oJsonOut.IntOf("symbols[0].payloadBytes") & @CRLF)
ConsoleWrite("ECI header: " & $oJsonOut.HasMember("symbols[0].selectedEncoding.eci") & @CRLF)

;  Without an ECI header (qa_output/qr_utf8.png):

;  image

;  The same text with an ECI header declaring UTF-8.
$oJson.UpdateInt("encoding.eci",26)
$oJson.UpdateString("output.path","qa_output/qr_utf8_eci.png")
$bSuccess = $oFmt.QrCode("generate",$oJson,$oJsonOut)
If ($bSuccess = False) Then
    ConsoleWrite($oFmt.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("with encoding.eci = 26, ECI header: " & $oJsonOut.HasMember("symbols[0].selectedEncoding.eci") & ", value " & $oJsonOut.IntOf("symbols[0].selectedEncoding.eci") & @CRLF)

;  With the ECI header (qa_output/qr_utf8_eci.png).  Both scan as the same text:

;  image

;  Sample output:

;  characters: 17
;  bytes encoded: 20
;  ECI header: False
;  with encoding.eci = 26, ECI header: True, value 26