# String::fromUTF8 stops at non-UTF ansi Umlaut

**URL:** <https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434>\
**Category:** General JUCE discussion\
**Created:** [July 3, 2010, 12:48pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434 "2010-07-03T12:48:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [July 3, 2010, 12:48pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/1 "2010-07-03T12:48:25Z")

</div>

I noticed the new build of Jucer 1.11 doesn’t load my old jucer-cpp files any more.  
Older builds are working.

String::createStringFromData uses String::fromUTF8 (data, size) for encoding, and it breaks at my non-UTF8 ANSI “Ü” Hex 0xFC

[code]while (–numExtraValues \>= 0 && i \< (size\_t) bufferSizeBytes)  
{  
const char nextByte = buffer[i];  
if ((nextByte & 0xc0) != 0x80)  
break;

[/code]  
Did you change here something recently?

Maybe its better not to break and truncate the file, better ignore the character or use the ISO8859 table as a fallback ?

CallStack

String::fromUTF8 (data, size)  
String::createStringFromData  
FileInputStream::readEntireStreamAsString();  
String File::loadFileAsString()  
JucerDocument\* loadDocumentFromFile

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 3, 2010, 3:26pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/2 "2010-07-03T15:26:29Z")

</div>

Probably a better idea to actually save the cpp file in utf8, isn’t it…? I’d have thought these days that most editors would use utf8 by default?

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [July 3, 2010, 6:07pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/3 "2010-07-03T18:07:04Z")

</div>

> [@](#):
>
> Probably a better idea to actually save the cpp file in utf8, isn’t it…?

yes for me of course (i only edited the file with VC++ mmhhh… )

But String::fromUTF8 will be used in many circumstances, and a normal user doesn’t see the problem behind, he only see that his application does not work properly

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [January 21, 2011, 6:35pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/4 "2011-01-21T18:35:57Z")

</div>

jules, this issue is still present in the old and the new Jucer, if there is a unknown char, the processing should not completely stopped, either it shoud ignore the char or it should jassert or give a error message back

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 21, 2011, 6:42pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/5 "2011-01-21T18:42:01Z")

</div>

Could you email me an offending file so I can have a go myself?

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [January 21, 2011, 7:09pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/6 "2011-01-21T19:09:40Z")

</div>

try to add this file into a jucer 3 project, and open it in the jucer text-editor, you will only see the first line

---

<div class="post-metadata">

**Author:** ![SwingCoder](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@SwingCoder](https://forum.juce.com/u/SwingCoder)\
**Post date:** [January 21, 2011, 7:13pm UTC](https://forum.juce.com/t/string-fromutf8-stops-at-non-utf-ansi-umlaut/5434/7 "2011-01-21T19:13:52Z")

</div>

When the code comment was Chinese, the problem will become even more serious, even undermine all code of post-edit or added.
