- 0 minutes to read

Character Encoding

A logged message body is stored as bytes. To search it, show it, transform it with a Stylesheet, or let you download it as text, Nodinite must know which character encoding turns those bytes into characters. If the encoding is wrong, Ä, é, and ø turn into garbage, Search Field Expressions miss values, and XML parsers fail on an unexpected byte order mark (BOM). New 7.11

From Nodinite 7.11, you set the encoding where it belongs, and Nodinite uses it consistently everywhere the message is read:

  • Per Message Type – the default for every message of that format (UTF-8 (without BOM) unless you change it)
  • Per Endpoint – override the Message Type when the same format arrives in a different encoding on a specific Endpoint
  • Per XML body – an encoding named in the XML declaration of the body is honored automatically
  • Per Log Event – override everything for a single message with the ExtendedProperties/1.0#Encoding context property
  • Base64 Decode into any encoding – decode Base64-wrapped payloads into the encoding the original content used
  • Download converted to – download a message converted to the encoding a receiving system needs

Understanding encoding resolution

Nodinite picks one encoding for each message by checking four levels, highest priority first. The first level that holds a value wins.

flowchart TD A["fa:fa-envelope Log Event body (bytes)"] --> B{"1. Context property
ExtendedProperties/1.0#Encoding
set on the Log Event?"} B -- Yes --> R["fa:fa-check Resolved encoding"] B -- No --> X{"2. XML declaration
in the body names
an encoding?"} X -- Yes --> R X -- No --> C{"3. Endpoint
Character encoding set?
(not Inherit from the Message Type)"} C -- Yes --> R C -- No --> D["4. Message Type
Character encoding
(default: UTF-8 without BOM)"] D --> R R --> U1["fa:fa-gears Logging Service
processing and re-indexing"] R --> U2["fa:fa-eye View Message
and Stylesheets"] R --> U3["fa:fa-wand-magic-sparkles Search Field Wizard"] R --> U4["fa:fa-download Download converted to"] style A fill:#2678BD style B fill:#9E59BB style X fill:#D5396D style C fill:#E47528 style D fill:#3F827B style R fill:#93d16d

Encoding resolution: the per-event context property (purple, priority 1) beats the XML declaration (pink, priority 2), which beats the Endpoint (orange, priority 3), which beats the Message Type (teal, priority 4). The resolved encoding (green) is used everywhere Nodinite reads the message as text.

The four levels explained

Priority Level Where it comes from Default Use it when
1 Context property ExtendedProperties/1.0#Encoding The Log Event context, from your logging code or Log Agent Not set One message differs from the rest, or the sender knows the encoding at runtime
2 XML declaration The body itself, for example <?xml version="1.0" encoding="windows-1252"?> Not set Automatic for XML bodies that declare their encoding; nothing to configure
3 Endpoint Character encoding on the Endpoint edit page, or the Web API Inherit from the Message Type One Endpoint receives a format in another encoding than usual, such as a legacy FTP drop in Windows-1252
4 Message Type Character encoding on the Message Type edit page, or the Web API UTF-8 (without BOM) A message format always uses the same encoding

Tip

Set the encoding on the Message Type first. Add an Endpoint override only where a format arrives differently, and keep the context property for the exceptions your code knows about at runtime.

Character encoding options on the Message Type edit page (7.11)
The same list of encodings is offered on Message Types and Endpoints; the Id next to each option is the numeric value the Log API accepts.

Where Nodinite uses the resolved encoding

Feature What happens Configured by
Logging Service processing and re-indexing Decodes the body before evaluating Search Field Expressions, so extracted values have the right characters Resolved encoding
View Message (Log Views) The encoding dropdown opens on the resolved encoding; its tooltip says where it came from, such as From the Message Type Resolved encoding (you can still pick another)
View details (Log Views) Shows the Encoding under Message Type Resolved encoding
View message formatted as… (Stylesheets) Converts the body from the resolved encoding to UTF-8 before inserting it into the Stylesheet Resolved encoding
Search Field Wizard The Encoding dropdown on the Test step opens on the resolved encoding Resolved encoding (you can still pick another)
Download converted to Reads the body with the resolved encoding and saves it in the target encoding you choose You choose the target
Download Saves the original bytes, unchanged Not affected
Repair message Writes the message in its original encoding, unless you choose the encoding configured in the editor Separate setting, see Download, repair, and resubmit

Supported encodings

The table lists each encoding, its numeric value, and every input the Log API accepts for it in the ExtendedProperties/1.0#Encoding context property. The dropdowns in the Web Client show the display names, such as UTF-8 (without BOM) and Base64 Decode into UTF-8 (without BOM).

Encoding (value) Accepted inputs
UTF8 (1) 1, UTF8 / utf-8, UTF-8 (without BOM)
UTF8WithBom (2) 2, UTF8WithBom / UTF-8 (with BOM) / utf-8 with bom, utf-8-bom
UTF16 (3) 3, UTF16 / utf-16, UTF-16 (without BOM), utf-16le, unicode
UTF16WithBom (4) 4, UTF16WithBom / UTF-16 (with BOM), utf-16-bom
ASCII (5) 5, ASCII, us-ascii
Windows1252 (6) 6, Windows1252 / Windows-1252, cp1252
ISO8859_1 (7) 7, ISO8859_1 / ISO-8859-1, latin1 / latin-1
EBCDIC (8) 8, EBCDIC, EBCDIC (IBM037), ibm037, cp037
Base64UTF8 (11) 11, Base64UTF8 / base64:utf-8, Base64 Decode into UTF-8 (without BOM), base64:UTF-8 (without BOM)
Base64UTF8WithBom (12) 12, Base64UTF8WithBom / base64:UTF-8 (with BOM), Base64 Decode into UTF-8 (with BOM), base64:utf-8-bom
Base64UTF16 (13) 13, Base64UTF16 / base64:utf-16, Base64 Decode into UTF-16 (without BOM), base64:UTF-16 (without BOM), base64:utf-16le, base64:unicode
Base64UTF16WithBom (14) 14, Base64UTF16WithBom / base64:UTF-16 (with BOM), Base64 Decode into UTF-16 (with BOM), base64:utf-16-bom
Base64ASCII (15) 15, Base64ASCII / base64:ascii, Base64 Decode into ASCII, base64:us-ascii
Base64Windows1252 (16) 16, Base64Windows1252 / base64:windows-1252, Base64 Decode into Windows-1252, base64:cp1252
Base64ISO8859_1 (17) 17, Base64ISO8859_1 / base64:iso-8859-1, Base64 Decode into ISO-8859-1, base64:latin1
Base64EBCDIC (18) 18, Base64EBCDIC / base64:ebcdic, Base64 Decode into EBCDIC (IBM037), base64:EBCDIC (IBM037), base64:ibm037, base64:cp037

Important

A value that matches none of the accepted inputs falls back to UTF-8. Check the spelling when special characters look wrong for messages that carry the context property.

With BOM vs without BOM

A byte order mark (BOM) is an invisible marker at the start of a UTF-8 or UTF-16 file. Some systems require it, others choke on it.

Option Reads the BOM Keeps the BOM in the text
UTF-8 (without BOM) / UTF-16 (without BOM) Yes No – the BOM is removed
UTF-8 (with BOM) / UTF-16 (with BOM) Yes Yes – the BOM stays, so you can see it and send it on

In View Message, select a with BOM encoding and turn on Show hidden characters to see whether a message starts with a BOM.

A BOM shown as a hidden character in View Message (7.11)
With UTF-8 (with BOM) selected and Show hidden characters on, the BOM appears as a red BOM marker before the first character.

Base64 Decode into an encoding

Some platforms log the body as Base64 text, for example when the original content is binary or wrapped in JSON. A Base64 Decode into … encoding first decodes the Base64 text to bytes, and then reads those bytes with the encoding named after into.

Note

In earlier versions, the single Base64 Decode option always decoded into UTF-8. From 7.11 it is named Base64 Decode into UTF-8 (without BOM), and there is one Base64 Decode into … option for every other supported encoding, including UTF-8 (with BOM).

Set the encoding for a single Log Event

Add the ExtendedProperties/1.0#Encoding key to the context of the Log Event with any accepted input from the Supported encodings table. This value overrides the XML declaration, the Endpoint, and the Message Type.

{
  "Context": {
    "ExtendedProperties/1.0#Encoding": "Windows-1252"
  }
}

The numeric value works too, which is convenient from code that already uses the enumeration:

{
  "Context": {
    "ExtendedProperties/1.0#Encoding": "6"
  }
}

See Context Options for the other keys you can set on a Log Event.

Download, repair, and resubmit

These actions look alike but treat encoding differently. Repair message is deliberately kept apart from the encoding settings on this page, so a repaired message reaches the receiving system in the same encoding it originally arrived in.

Action Where Encoding of the result
Download View Message, View details, Actions menu Original bytes, unchanged
Download converted to The download-converted button in View Message, the Download menu on View details, and the Web API The target you choose: UTF-8 or UTF-16 with or without BOM, ASCII, Windows-1252, ISO-8859-1, or EBCDIC (IBM037)
Repair message View details > Repair Use original encoding by default; select Use the encoding configured in the editor to write it in the encoding chosen in the editor's dropdown instead

Read more in What is a Log View?.

Automate with the Web API

The Web API exposes the character encoding on both the Message Type and the Endpoint models, so you can set it from DevOps pipelines together with the rest of your Repository Model. The Web API download operation accepts a target encoding as a parameter, which works like Download converted to in the Web Client.

Next Steps