Table of Contents

Class S57LexicalLevels

Namespace
EncDotNet.S57
Assembly
EncDotNet.S57.dll

Provides methods to choose the S-57 lexical levels (DSSI AALL and NALL) for character data.

public static class S57LexicalLevels
Inheritance
S57LexicalLevels
Inherited Members

Remarks

These methods make the same checks as S57DocumentWriter, so a level they pick is one the writer can encode the values at (S-57 Edition 3.1, Part 3, clause 2.4).

UCS-2 covers the Basic Multilingual Plane only. A character outside it, which .NET holds as a UTF-16 surrogate pair (an emoji, for example), can't be encoded at any lexical level, and an unpaired surrogate can't either.

Methods

CanEncode(string?, S57LexicalLevel)

Gets whether a value can be encoded at a lexical level.

public static bool CanEncode(string? value, S57LexicalLevel level)

Parameters

value string

The value. null is treated as an empty string.

level S57LexicalLevel

The lexical level.

Returns

bool

true if every character of value is in the character set of level; otherwise, false.

Exceptions

ArgumentOutOfRangeException

level isn't 0, 1 or 2.

Lowest(IEnumerable<string?>)

Gets the lowest lexical level that can encode every one of a set of values.

public static S57LexicalLevel Lowest(IEnumerable<string?> values)

Parameters

values IEnumerable<string>

The values, such as the ATTF or NATF attribute values of a data set. null values are treated as empty strings.

Returns

S57LexicalLevel

Ascii if every value is ASCII (including when there are no values), Latin1 if every value is ISO 8859-1, and otherwise Ucs2.

Exceptions

ArgumentNullException

values is null.

ArgumentException

A value has a character outside the Basic Multilingual Plane (a surrogate pair) or an unpaired surrogate, which no lexical level can encode.

WithLowestLevels(S57Document)

Returns a copy of a document whose DSSI lexical levels (AALL and NALL) are the lowest that can encode its feature records' ATTF and NATF values.

public static S57Document WithLowestLevels(S57Document document)

Parameters

document S57Document

The document. It must have a data set identification (DSID).

Returns

S57Document

A copy of document whose AttfLexicalLevel and NatfLexicalLevel are set from Lowest(IEnumerable<string?>). The levels may be lower than the document's.

Remarks

S57DocumentWriter writes the levels the document holds. Call this before writing a document built in memory to have the writer use the lowest levels instead.

Exceptions

ArgumentNullException

document is null.

ArgumentException

The document has no data set identification; an ATTF value needs UCS-2, which ATTF doesn't allow; or a value has a character that no lexical level can encode.