# Some predicates do not work properly with supplementary Unicode characters in Windows

**URL:** <https://swi-prolog.discourse.group/t/some-predicates-do-not-work-properly-with-supplementary-unicode-characters-in-windows/6112>\
**Category:** Predicate\
**Tags:** bug\
**Created:** [January 17, 2023, 1:56pm UTC](https://swi-prolog.discourse.group/t/some-predicates-do-not-work-properly-with-supplementary-unicode-characters-in-windows/6112 "2023-01-17T13:56:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![UweR](https://avatars.discourse-cdn.com/v4/letter/u/f475e1/32.png) [@UweR](https://swi-prolog.discourse.group/u/UweR)\
**Post date:** [January 17, 2023, 1:56pm UTC](https://swi-prolog.discourse.group/t/some-predicates-do-not-work-properly-with-supplementary-unicode-characters-in-windows/6112/1 "2023-01-17T13:56:53Z")

</div>

I saw that with stable version of 9.0.x now also supplementary Unicode characters (i.e., \>U+FFFF) are supported in Windows. Thanks for that.

I’ve done some checks with Windows 64 bit version of SWI-Prolog 9.0.3 with such Unicode characters and found following issues:

xml\_quote\_attribute/2 does not create the XML entities correctly on Windows. It converts the high and low surrogates separately, which creates invalid content:

```prolog
?- xml_quote_attribute('🙂',X).
Windows:
X = '&#55357;&#56898;'.
Linux:
X = '&#128578;'.

```

string\_length/2 on atoms does not count correctly the number of characters (Unicode codepoints), but atom\_length/2 does. According to documentation they should be functionally equivalent.

```prolog
?- atom_length('🙂',AL),string_length('🙂',SL).
Windows:
AL = 1, SL = 2.
Linux:
AL = SL, SL = 1.

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [January 17, 2023, 4:46pm UTC](https://swi-prolog.discourse.group/t/some-predicates-do-not-work-properly-with-supplementary-unicode-characters-in-windows/6112/2 "2023-01-17T16:46:02Z")

</div>

> [@UweR](#):
>
> [xml\_quote\_attribute/2](https://www.swi-prolog.org/pldoc/doc_for?object=xml_quote_attribute/2) does not create the XML entities correctly on Windows.

Only the core system and some of the extensions are supposed to handle the full Unicode range on Windows ☹ library(sgml) is not part of that. I pushed some patches that surely deal with this and a lot more. How complete UTF-16 support is, I do not know. If you want to help, download the next daily version and provide test cases.

> [@UweR](#):
>
> [string\_length/2](https://www.swi-prolog.org/pldoc/doc_for?object=string_length/2) on atoms does not count correctly the number of characters (Unicode codepoints)

Thanks for reporting. They now share the implementation, so this problem is gone 🙂
