UTF-16 Encoding Detection in Streaming XML Without BOM

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Computing devices and systems face challenges in detecting and determining the UTF-16 encoding scheme and its endianness for XML data streams without a byte-order mark (BOM), particularly in mixed encoding environments where XML data from multiple sources may use different encoding schemes.

Innovation Solution

A method that monitors incoming data streams for specific byte patterns, such as the presence of 0x3C bytes and NULL 0x00 bytes, to automatically detect and determine the UTF-16 encoding scheme and endianness, allowing for accurate processing even when XML data does not start with a BOM.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If XML data is encoded in UTF-16 without a byte-order mark (BOM), then the data can be transmitted in a more compact form and legacy devices can be supported, but the computing device cannot automatically detect the encoding scheme and endianness

Engineering Contradiction:
Improvecompatibility with legacy devicesVSAvoiddetection of encoding scheme
Core Design Contradiction:
Adaptability or versatilityVSDifficulty of detecting and measuring

Solution Approach 1:

The patent applies preliminary action by examining bytes before the XML declaration to predict the encoding scheme. The system looks at the 2-6 bytes preceding the XML start tag and uses patterns of NULL bytes and non-NULL bytes to determine whether UTF-16LE or UTF-16BE encoding is used, allowing the device to be prepared with the correct encoding detection before actually encountering the XML declaration.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent changes the detection parameter from relying on BOM (which is absent) to analyzing the pattern of NULL and non-NULL bytes in the preamble region. By monitoring the presence and position of NULL bytes relative to the XML declaration and using state machine transitions based on these byte patterns, the system adapts its detection mechanism to work without BOM while maintaining accuracy.

Inventive Principle:
Principle #35Parameter changes

2Measurement precision

If the system monitors incoming data streams for byte patterns to detect UTF-16 encoding, then accurate detection without BOM is achieved, but the processing time and computational resources increase

Engineering Contradiction:
Improveaccuracy of encoding detectionVSAvoidprocessing time for detection
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent segments the detection process into distinct states (STATE_0 through STATE_7) that process bytes in a systematic sequence. The state machine divides the preamble region into specific segments (bytes before XML declaration, bytes at the declaration position) and applies different detection logic to each segment, making the complex detection process more efficient and manageable.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent examines a limited portion of the data stream (only the 2-6 bytes before the XML declaration) rather than analyzing the entire stream. This partial action approach provides sufficient information for accurate detection while minimizing processing time and resource consumption.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS9720885B2Detection of UTF-16 encoding in streaming XML data without a byte-order mark and related printers, systems, methods, and computer program products
Publication Date: 2017.08.01 ZEBRA TECHNOLOGIES CORP
  • US9720885B2 patent drawing
  • US9720885B2 patent drawing
  • US9720885B2 patent drawing

AI summary

Provided are printers and other electronic devices, systems, methods, and computer program products that automatically detect and determine UTF-16 encoding schemes and endiannesss thereof in an incoming XML data steam for XML declarations without a UTF-16 byte-order mark (BOM) or encoding declaration. This allows for the automatic and unambiguous accurate detection of UTF-16 encoded XML data within a mixed encoding environment, such as from multiple sources using more than one encoding scheme, even when XML data does not start with a BOM or encoding declaration.