# Default encoding not UTF-8?

**URL:** <https://forum.xojo.com/t/default-encoding-not-utf-8/83286>\
**Category:** Windows\
**Created:** [November 21, 2024, 4:50am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286 "2024-11-21T04:50:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Linacre1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@Mike\_Linacre1](https://forum.xojo.com/u/Mike_Linacre1)\
**Post date:** [November 21, 2024, 4:50am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286/1 "2024-11-21T04:50:40Z")

</div>

According to Xojo docs “Strings have a UTF-8 Encoding by default”

- [Encoding — Xojo documentation](https://documentation.xojo.com/api/text/encoding_text/encoding.html)

But when I create a string in Xojo 2023R4 (Windows), the default encoding is US-ASCII. Example:

Dim s as string  
dim enc as textencoding = s.encoding

How do I make the default encoding UTF-8, so that I don’t have to DefineEncoding for every string?

(Yes, “Read the Xojo documentation” - but where?)

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [November 21, 2024, 6:17am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286/2 "2024-11-21T06:17:16Z")

</div>

ascii IS utf-8. Put something in the string and then check it. Eg.,

Dim s as string = “abc”  
dim enc as textencoding = s.encoding

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [November 21, 2024, 7:13am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286/3 "2024-11-21T07:13:39Z")

</div>

Try creating a string with accented characters in it and see what the encoding is.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [November 21, 2024, 8:51am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286/4 "2024-11-21T08:51:51Z")

</div>

> [@Mike\_Linacre1](#):
>
> Read the Xojo documentation

In documentation, type [Strings](https://documentation.xojo.com/getting_started/using_the_xojo_language/data_types.html#getting-started-using-the-xojo-language-data-types-strings) and read.

There may be far other entries… like [Encoding](https://documentation.xojo.com/api/text/encoding_text/encoding.html#encoding), etc.

Look at the See also entry at this page bottom…

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [November 21, 2024, 9:11am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286/5 "2024-11-21T09:11:35Z")

</div>

> [@Mike\_Linacre1](#):
>
> Dim s as string  
> dim enc as textencoding = s.encoding

IIRC, empty strings don’t return the same encoding as would a non-empty one do.

---

<div class="post-metadata">

**Author:** ![Mike\_Linacre1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@Mike\_Linacre1](https://forum.xojo.com/u/Mike_Linacre1)\
**Post date:** [November 22, 2024, 2:38am UTC](https://forum.xojo.com/t/default-encoding-not-utf-8/83286/6 "2024-11-22T02:38:25Z")

</div>

Thanks, Tim, Eric and folks.

Yes, the default becomes UTF-8. My problem was that some strings are UTF-16. After discovering that, everything is explained.
