• API Overview
  • EBICS API
  • FinTS API
  • XS2A API
  • SEPA API
Search Results for

    Class SepaUtil

    Collection of useful constants and static utility methods for processing SEPA data.

    Inheritance
    System.Object
    SepaUtil
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Subsembly.Sepa
    Assembly: Subsembly.Sepa.dll
    Syntax
    public static class SepaUtil

    Fields

    MaxIdLen

    The maximum length of a SEPA identification. (35)

    Declaration
    public const int MaxIdLen = 35
    Field Value
    Type Description
    System.Int32

    MaxNmLen

    The maximum length of a party name in SEPA messages. (70)

    Declaration
    public const int MaxNmLen = 70
    Field Value
    Type Description
    System.Int32

    MaxRmtInfLen

    The maximum length of an unstructured remittance information string. (140)

    Declaration
    public const int MaxRmtInfLen = 140
    Field Value
    Type Description
    System.Int32

    NONREF

    String constant containing "NONREF".

    Declaration
    public const string NONREF = "NONREF"
    Field Value
    Type Description
    System.String

    NOTPROVIDED

    String constant containing "NOTPROVIDED".

    Declaration
    public const string NOTPROVIDED = "NOTPROVIDED"
    Field Value
    Type Description
    System.String

    SMNDA

    String constant "SMNDA".

    Declaration
    public const string SMNDA = "SMNDA"
    Field Value
    Type Description
    System.String

    StructuredCommunicationReference

    String constant StructuredCommunicationReference ("SCOR")

    Declaration
    public const string StructuredCommunicationReference = "SCOR"
    Field Value
    Type Description
    System.String

    UNBEKANNT

    String constant containing "UNBEKANNT".

    Declaration
    public const string UNBEKANNT = "UNBEKANNT"
    Field Value
    Type Description
    System.String

    UNKNOWN

    String constant containing "UNKNOWN".

    Declaration
    public const string UNKNOWN = "UNKNOWN"
    Field Value
    Type Description
    System.String

    Methods

    BuildID(String, String)

    Builds an ID with country code and MOD-97-10 check digits.

    Declaration
    public static string BuildID(string sCountryCode, string sReference)
    Parameters
    Type Name Description
    System.String sCountryCode

    Two upper case characters representing the country code that is included as the first two characters of the ID.

    System.String sReference

    A string of digits and upper case characters that represents the actual reference value that is included after the two check digits.

    Returns
    Type Description
    System.String

    An ID in the format "XX00REFERENCE", where "XX" is the country code, "00" are two MOD-97-10 check digits and "REFERENCE" is the given reference value.

    Exceptions
    Type Condition
    System.ArgumentNullException

    A parameter was null.

    System.ArgumentException

    The country code parameter did not consist of two upper case characters.

    CaptureAlphaNum(String)

    Captures digits and alpha characters from a given string. Converting lower case to upper case and skipping white space.

    Declaration
    public static string CaptureAlphaNum(string s)
    Parameters
    Type Name Description
    System.String s
    Returns
    Type Description
    System.String

    CheckCharset(Char)

    Checks whether the given character is an allowed SEPA character.

    Declaration
    public static bool CheckCharset(char ch)
    Parameters
    Type Name Description
    System.Char ch

    The character to be checked.

    Returns
    Type Description
    System.Boolean

    If the given character is a valid SEPA character, then true is returned. Otherwise false is returned.

    Remarks

    Banks must be able to support the Latin character set commonly used in international communication, as follows:

    a b c d e f g h i j k l m n o p q r s t u v w x y z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    0 1 2 3 4 5 6 7 8 9
    / - ? : ( ) . , ' +
    Space

    CheckCharset(String)

    Checks whether the given string contains only allowed SEPA characters.

    Declaration
    public static bool CheckCharset(string sText)
    Parameters
    Type Name Description
    System.String sText

    The string to be checked. This could be a Name, or a RemittanceInformation or any SEPA identification.

    Returns
    Type Description
    System.Boolean

    If the given text contains only valid characters, then true is returned. If any invalid character is found, then false is returned.

    See Also
    CheckCharset(Char)
    EnforceCharset(String, Char)

    CheckGermanCharset(Char)

    Checks whether the given character is an allowed SEPA character according to the German DK rules.

    Declaration
    public static bool CheckGermanCharset(char ch)
    Parameters
    Type Name Description
    System.Char ch

    The character to be checked.

    Returns
    Type Description
    System.Boolean

    If the given character is an allowed SEPA character, then true is returned. Otherwise false is returned.

    Remarks
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    0 1 2 3 4 5 6 7 8 9
    / - ? : ( ) . , ' +
    Ä Ö Ü ä ö ü ß & * $ %
    Space

    CheckGermanCharset(String)

    Checks whether the given string contains only SEPA characters allowed in the German DK SEPA specification.

    Declaration
    public static bool CheckGermanCharset(string sText)
    Parameters
    Type Name Description
    System.String sText

    The string to be checked. This could be a Name, or a RemittanceInformation or any SEPA identification.

    Returns
    Type Description
    System.Boolean

    If the given text contains only valid characters, then true is returned. If any invalid character is found, then false is returned.

    See Also
    CheckGermanCharset(Char)
    EnforceGermanCharset(String, Char)

    CheckIdentification(String)

    Declaration
    public static bool CheckIdentification(string sIdentification)
    Parameters
    Type Name Description
    System.String sIdentification

    The identification value to check. Must not be null. An empty string is not considered to be a valid identification.

    Returns
    Type Description
    System.Boolean

    If the given sIdentification is a valid identification value, then true is returned. Otherwise false is returned.

    Remarks

    In addition to length and character set, this also checks that the identification does not start with a slash "/", end with a slash "/", or contain a double slash "//".

    Exceptions
    Type Condition
    System.ArgumentNullException

    CheckTagName(String)

    Checks whether the given string contains only valid XML tag name characters.

    Declaration
    public static bool CheckTagName(string sTagName)
    Parameters
    Type Name Description
    System.String sTagName

    The XML tag name to be checked.

    Returns
    Type Description
    System.Boolean

    If the given tag name contains only valid tag name characters, then true is returned. If any invalid character is found, then false is returned.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The parameter was null.

    System.ArgumentException

    The parameter was an empty string.

    DecimalPlaces(Decimal)

    Computes the numer of significant decimal places in a decimal amount.

    Declaration
    public static int DecimalPlaces(decimal d)
    Parameters
    Type Name Description
    System.Decimal d
    Returns
    Type Description
    System.Int32
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    The parameter d was a negative value.

    EnforceCharset(String, Char)

    Creates a valid SEPA string from any string.

    Declaration
    public static string EnforceCharset(string sText, char chSubstituteChar = '.')
    Parameters
    Type Name Description
    System.String sText

    The text which shall be converted to a string that contains only valid SEPA characters. If this is null, then the return value is null, too.

    System.Char chSubstituteChar

    The character that will be used to replace any invalid characters that do not have a special replacement character in the input string. This parameter is defaulted to a full stop '.'.

    Returns
    Type Description
    System.String

    A valid SEPA string made from the input string where all invalid characters have been replaced by the substitute character.

    Remarks

    This method replaces the German umlaut characters 'ÄÖÜäöüß' with their non-decorated base characters 'AOUaous'. The ampersand '&' is replaced by a plus '+'. All other invalid characters are replaced by the given substitution character.

    Exceptions
    Type Condition
    System.ArgumentException

    The given substitute character was itself not a valid SEPA character.

    EnforceGermanCharset(String, Char)

    Creates a valid SEPA string from any string according to the German DK SEPA specification.

    Declaration
    public static string EnforceGermanCharset(string sText, char chSubstituteChar = '.')
    Parameters
    Type Name Description
    System.String sText

    The text which shall be converted to a string that contains only valid SEPA characters. If this is null, then the return value is null, too.

    System.Char chSubstituteChar

    The character that will be used to replace any invalid characters that do not have a special replacement character in the input string. This parameter is defaulted to a full stop '.'.

    Returns
    Type Description
    System.String

    A valid SEPA string made from the input string where all invalid characters have been replaced by the substitute character.

    Exceptions
    Type Condition
    System.ArgumentException

    The given substitute character was itself not a valid SEPA character.

    EnforceGermanName(String)

    Enforces a valid SEPA name from a given string according to the German DK SEPA specification.

    Declaration
    public static string EnforceGermanName(string sName)
    Parameters
    Type Name Description
    System.String sName
    Returns
    Type Description
    System.String

    A valid SEPA name string derived from the given name parameter. If the parameter was null or an empty string, then the string constant UNBEKANNT will be returned.

    Remarks

    If the given name is longer than MaxNmLen characters, it will be truncated. The string is then passed to EnforceGermanCharset(String, Char) in order to enforce a valid character set. The resulting string is returned.

    EnforceIdentification(String)

    Enforces a valid SEPA identification from a given string.

    Declaration
    public static string EnforceIdentification(string sIdentification)
    Parameters
    Type Name Description
    System.String sIdentification

    The identification string to process. This may be null, or an empty string.

    Returns
    Type Description
    System.String

    A valid SEPA identification string derived from the given sIdentification parameter. If the parameter was null or an empty string, or consists solely of whitespace, then the string constant NOTPROVIDED will be returned.

    Remarks

    If the given string is longer than MaxIdLen characters, it will be truncated. The string is then passed to EnforceCharset(String, Char) in order to enforce a valid character set. The resulting string is returned.

    Note that a valid MandateIdentification must not contain blank characters in addition to the enforcement done here!

    EnforceIdentification(String, String)

    Enforces a valid SEPA identification from a given string.

    Declaration
    public static string EnforceIdentification(string sIdentification, string sDefault)
    Parameters
    Type Name Description
    System.String sIdentification

    The identification string to process. This may be null, or an empty string.

    System.String sDefault

    The default string to return in case the sIdentification is null, empty, or consists solely of whitespace.

    Returns
    Type Description
    System.String

    EnforceName(String)

    Enforces a valid SEPA name from a given string.

    Declaration
    public static string EnforceName(string sName)
    Parameters
    Type Name Description
    System.String sName
    Returns
    Type Description
    System.String

    A valid SEPA name string derived from the given name parameter. If the parameter was null or an empty string, then the string constant UNKNOWN will be returned.

    Remarks

    If the given name is longer than MaxNmLen characters, it will be truncated. The string is then passed to EnforceCharset(String, Char) in order to enforce a valid character set. The resulting string is returned.

    EnforceName(String, String)

    Declaration
    public static string EnforceName(string sName, string sDefault)
    Parameters
    Type Name Description
    System.String sName
    System.String sDefault
    Returns
    Type Description
    System.String

    GenerateIdentification(String)

    Generates a new and unique SEPA identification.

    Declaration
    public static string GenerateIdentification(string sPrefix)
    Parameters
    Type Name Description
    System.String sPrefix

    Optional prefix that will be included in the generated identification. If given, it must be shorter than MaxIdLen.

    Returns
    Type Description
    System.String

    Generates an unique numeric character identification based on the current time. The returned string can be used as a unique SEPA identifier.

    Exceptions
    Type Condition
    System.ArgumentException

    The given prefix was too long.

    GetAllSepaCountryCodes()

    Returns a sorted array of all country codes of all countries that belong to the SEPA payments area.

    Declaration
    public static string[] GetAllSepaCountryCodes()
    Returns
    Type Description
    System.String[]

    GetCurrencyDecimals(String)

    Returns the number of decimal places of a particular currency.

    Declaration
    public static int GetCurrencyDecimals(string sCcy)
    Parameters
    Type Name Description
    System.String sCcy

    ISO currency code of the requested currency. If this is null, empty or an invalid or unknown currency code, then the default value 2 is returned.

    Returns
    Type Description
    System.Int32

    Number of decimals of the requested currency. Currently either 0, 2, or 3.

    Remarks

    Known currencies may have zero, two, or three decimals. If an unknown currency is requested, then the default value two is returned. This method never throws an exception.

    IsAlpha(Char)

    Indicates whether the given character is an upper case letter.

    Declaration
    public static bool IsAlpha(char ch)
    Parameters
    Type Name Description
    System.Char ch

    Character to test.

    Returns
    Type Description
    System.Boolean

    True if the character is an upper case letter in the range from 'A' through 'Z'.

    IsAlpha(String)

    Tests whether the entire string contains only upper case letters.

    Declaration
    public static bool IsAlpha(string s)
    Parameters
    Type Name Description
    System.String s

    The string to test.

    Returns
    Type Description
    System.Boolean

    True if all characters are upper case letters in the range from 'A' through 'Z'.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The parameter was null.

    IsAlphaNumeric(Char)

    Indicates whether the given character is a digit or an upper case letter.

    Declaration
    public static bool IsAlphaNumeric(char ch)
    Parameters
    Type Name Description
    System.Char ch

    Character to test.

    Returns
    Type Description
    System.Boolean

    True if the character is an upper case letter in the range from 'A' through 'Z' or a digit in the range from '0' through '9'.

    IsAlphaNumeric(String)

    Tests whether the entire string contains only digits or upper case letters.

    Declaration
    public static bool IsAlphaNumeric(string s)
    Parameters
    Type Name Description
    System.String s

    The string to test.

    Returns
    Type Description
    System.Boolean

    True if all characters are upper case letters in the range from 'A' through 'Z' or digits in the range from '0' through '9'.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The parameter was null.

    IsEuCountryCode(String)

    Determines whether the given country code is a valid EU member country code.

    Declaration
    public static bool IsEuCountryCode(string sCountryCode)
    Parameters
    Type Name Description
    System.String sCountryCode
    Returns
    Type Description
    System.Boolean

    If the parameter sCountryCode is null, or an invalid country code, or not a country code of a country that is an EU member, then false is returned. Otherwise true is returned.

    See Also
    IsValidCountryCode(String)

    IsLatin1(Char)

    Indicates whether the given character is a printable character from the Latin 1 (ISO 8859-1) character set.

    Declaration
    public static bool IsLatin1(char ch)
    Parameters
    Type Name Description
    System.Char ch

    Character to test.

    Returns
    Type Description
    System.Boolean

    True if the character is a printable latin 1 character in the range from '\u0020' through '\u007E' or in the range from '\u00A0' through '\u00FF'.

    IsLatin1(String)

    Tests whether the entire string contains only printable characters from the Latin 1 (ISO 8859-1) character set.

    Declaration
    public static bool IsLatin1(string s)
    Parameters
    Type Name Description
    System.String s

    The string to test.

    Returns
    Type Description
    System.Boolean

    True if all characters are printable latin 1 characters in the range from '\u0020' through '\u007E' or in the range from '\u00A0' through '\u00FF'.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The parameter was null.

    IsNumeric(Char)

    Indicates whether the given character is a digit.

    Declaration
    public static bool IsNumeric(char ch)
    Parameters
    Type Name Description
    System.Char ch

    Character to test.

    Returns
    Type Description
    System.Boolean

    True if the character is a digit in the range from '0' through '9'.

    IsNumeric(String)

    Tests whether the entire string contains digits only.

    Declaration
    public static bool IsNumeric(string s)
    Parameters
    Type Name Description
    System.String s

    The string to test.

    Returns
    Type Description
    System.Boolean

    True if all characters are digits in the range from '0' through '9'.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The parameter was null.

    IsSepaCountryCode(String)

    Determines whether the given country code is a valid country code of a SEPA country.

    Declaration
    public static bool IsSepaCountryCode(string sCountryCode)
    Parameters
    Type Name Description
    System.String sCountryCode
    Returns
    Type Description
    System.Boolean

    If the parameter sCountryCode is null, or an invalid country code, or not a country code of a country that belongs to SEPA, then false is returned. Otherwise true is returned.

    See Also
    IsValidCountryCode(String)

    IsValidCountryCode(String)

    Checks the syntax of the given country code.

    Declaration
    public static bool IsValidCountryCode(string sCountryCode)
    Parameters
    Type Name Description
    System.String sCountryCode
    Returns
    Type Description
    System.Boolean
    Remarks

    This only validates the syntax and does not check whether the given country actually exists. A valid country code consists of exactly two upper case letters (A-Z).

    IsValidCurrencyCode(String)

    Checks the syntax of the given currency code.

    Declaration
    public static bool IsValidCurrencyCode(string sCurrencyCode)
    Parameters
    Type Name Description
    System.String sCurrencyCode
    Returns
    Type Description
    System.Boolean
    Remarks

    This only validates the syntax and does not check whether the given currency actually exists. A valid currency code consists of exactly three upper case letters (A-Z).

    IsValidID(String)

    Validates an ID including a MOD-97-10 validation.

    Declaration
    public static bool IsValidID(string sID)
    Parameters
    Type Name Description
    System.String sID

    The ID to validate. This could be an IBAN, a creditor reference or a creditor ID, or any other ID that follows the same basic pattern.

    Returns
    Type Description
    System.Boolean

    If the given ID is valid, then true is returned. Otherwise false is returned.

    Remarks

    The validation checks whether the first two characters are upper case letters, and the subsequent two characters are valid MOD-97-10 check digits. The remainder must consist of digits and upper case letters, only.

    NullTrim(String)

    Trims whitespace from a string, returning null, when the trimmed string is empty.

    Declaration
    public static string NullTrim(string s)
    Parameters
    Type Name Description
    System.String s

    String to be trimmed. May be null.

    Returns
    Type Description
    System.String

    ToDateTimeFromDt(String)

    Declaration
    public static DateTime ToDateTimeFromDt(string sDt)
    Parameters
    Type Name Description
    System.String sDt
    Returns
    Type Description
    System.DateTime

    ToLocalDateTime(String)

    Converts a ISO date time specification to a DateTime of kind LocalTime.

    Declaration
    public static DateTime ToLocalDateTime(string s)
    Parameters
    Type Name Description
    System.String s
    Returns
    Type Description
    System.DateTime

    If the parameter was null, or an empty string, or malformed, then DateTime.MinValue is returned. Otherwise a local DateTime is returned.

    ToLocalTime(DateTime)

    Converts a given DateTime to a DateTime in local time.

    Declaration
    public static DateTime ToLocalTime(DateTime tDateTime)
    Parameters
    Type Name Description
    System.DateTime tDateTime
    Returns
    Type Description
    System.DateTime
    Remarks

    This method differs from DateTime.ToLocalTime, that it does not assume that an DateTimeKind.Unspecified is a UTC time stamp, but assumes that an unspecified kind already is a local time.

    Trim(String)

    Trims whitespace from a string.

    Declaration
    public static string Trim(string s)
    Parameters
    Type Name Description
    System.String s

    String to be trimmed. May be null.

    Returns
    Type Description
    System.String

    If the parameter s was null, then null is returned, otherwise the trimmed string is returned. If the given string consists solely of whitespace, then an empty string will be returned.

    Trim(String, Int32)

    Trims whitespace from a string and truncates to MaxLen.

    Declaration
    public static string Trim(string s, int nMaxLen)
    Parameters
    Type Name Description
    System.String s

    String to be trimmed. May be null.

    System.Int32 nMaxLen

    Max length of returned string.

    Returns
    Type Description
    System.String

    If the parameter s was null, then null is returned, otherwise the trimmed and truncated string is returned. The length of the returned string will be smaller or equal to MaxLen. If the given string consists solely of whitespace, then an empty string will be returned.

    TrimReference(String)

    Trims the given string using NullTrim(String). If the result is NONREF, or NOTPROVIDED, then null is returned. Otherwise the trimmed string is returned.

    Declaration
    public static string TrimReference(string s)
    Parameters
    Type Name Description
    System.String s

    String to be trimmed. May be null.

    Returns
    Type Description
    System.String

    Returns the trimmed string, or null.

    In This Article
    Back to top Copyright 2009-2025 Subsembly GmbH