Class SepaUtil
Collection of useful contants and static utility methods for processing SEPA data.
Inheritance
Inherited Members
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 |
System.ArgumentException | The country code parameter did not consist of two upper case characters. |
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 |
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 |
See Also
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 |
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 |
See Also
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 |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter was |
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 |
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 |
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 |
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 |
Returns
Type | Description |
---|---|
System.String | A valid SEPA name string derived from the given name parameter. If the parameter
was |
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)
Declaration
public static string EnforceIdentification(string sIdentification, string sDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIdentification | |
System.String | sDefault |
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 |
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[] |
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 |
|
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 |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter was |
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 |
|
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 |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter was |
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 |
|
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 |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter was |
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 |
|
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 |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter was |
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 |
See Also
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 |
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.
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 |
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 |
Returns
Type | Description |
---|---|
System.String | If the parameter |
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 |
System.Int32 | nMaxLen | Max length of returned string. |
Returns
Type | Description |
---|---|
System.String | If the parameter s was |