[xsde-users] XSD/e validates string length using byte count (strlen/.size()), not Unicode character count

Roger.Strandberg at seb.se Roger.Strandberg at seb.se
Thu Jul 2 10:04:45 EDT 2026


Hi All,


We have encountered that in ISO20022 and PACS008 the nm tag is 140 characters and using Polish ł and ó , those get counted as 2 chars.


  *   ó (U+00F3) = 2 bytes
  *   ł (U+0142) = 2 bytes

XSD:
<xs:simpleType name="Max140Text">
    <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:maxLength value="140"/>
    </xs:restriction>
</xs:simpleType>


As I see it this is a bug in string-common.cxx as it uses size_t n = str.size(); and not Unicode character count.
Should not XSD/e use something like:
size_t n = 0;
for (size_t i = 0; i < str.size(); ) {
    unsigned char c = str[i];
    if (c < 0x80) i += 1;
    else if ((c & 0xE0) == 0xC0) i += 2;
    else if ((c & 0xF0) == 0xE0) i += 3;
    else i += 4;
    ++n;
}

Best Regards

Roger Strandberg
Techdev, International Systems 1
Technology
SEB

Mobile: +46 70 7760785
Postal Address: SE-106 40 Stockholm
Office Address: Stjärntorget 4
E-mail: roger.strandberg@@seb.se<mailto:maud.bergwall at seb.se>
sebgroup.com<https://seb.se/>

Invoice address: Skandinaviska Enskilda Banken AB,  Accounts Payable, SE-106 40 Stockholm
Please consider the environment before printing this e-mail

CONFIDENTIALITY NOTICE
This e-mail is confidential and may contain legally privileged information. If you have received it by mistake, please inform us by reply e-mail and then delete it (including any attachments) from your system; you should not copy it or in any other way disclose its content to anyone. E-mail is susceptible to data corruption, interception, unauthorized amendment, tampering and virus. We do not accept liability for any such actions or the consequences thereof.



More information about the xsde-users mailing list