# Characters encoding bug?

**URL:** <https://forum.juce.com/t/characters-encoding-bug/6367>\
**Category:** The Projucer\
**Created:** [February 4, 2011, 10:35am UTC](https://forum.juce.com/t/characters-encoding-bug/6367 "2011-02-04T10:35:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hladik](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@hladik](https://forum.juce.com/u/hladik)\
**Post date:** [February 4, 2011, 10:35am UTC](https://forum.juce.com/t/characters-encoding-bug/6367/1 "2011-02-04T10:35:11Z")

</div>

Hello Jules,  
I am using a VC2008 Express built version of the old Jucer, since I have just updated my JUCE checkout and discovered that the binaries are no longer distributed.  
I have simply opened and then saved a number of .cpp files to have the Jucer automatically convert addButtonListener() calls to addListener(). But some files now contain incorrect characters in C++ comments.

Before:`// la correlazione accordo->scale è incompatibile con quella scala->accordi`  
After:`// la correlazione accordo->scale incompatibile con quella scala->accordi`

It looks like an encoding problem…

---

<div class="post-metadata">

**Author:** ![hladik](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@hladik](https://forum.juce.com/u/hladik)\
**Post date:** [February 4, 2011, 10:58am UTC](https://forum.juce.com/t/characters-encoding-bug/6367/2 "2011-02-04T10:58:07Z")

</div>

I’m also unable to open a single .cpp file, previously generated with the Jucer, that it now refuses with a “This wasn’t a valid Jucer .cpp file…” message. Tracking the Jucer code with the debugger, it seems that the second parameter in the call`int startLine = indexOfLineStartingWith (lines, T("BEGIN_JUCER_METADATA"), 0);` at line #470 of jucer\_JucerDocument.cpp gets translated to an empty string. So startLine becomes -1 and the entire loadDocumentFromFile() procedure fails.

---

<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:** [February 4, 2011, 12:07pm UTC](https://forum.juce.com/t/characters-encoding-bug/6367/3 "2011-02-04T12:07:35Z")

</div>

The jucer expects the files to be in utf-8 - and since I’ve made the string classes more robust, I guess that the new version is rejecting any illegal characters that it finds, to make its input valid utf-8. Are you using the latest tip? (if not, I think the utf-8 parser in the 1.52 release would stop when it encountered an illegal character, but in the most recent check-ins, it ignores it and carries on)

---

<div class="post-metadata">

**Author:** ![hladik](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@hladik](https://forum.juce.com/u/hladik)\
**Post date:** [February 5, 2011, 12:32pm UTC](https://forum.juce.com/t/characters-encoding-bug/6367/4 "2011-02-05T12:32:49Z")

</div>

OK, now I understand, I didn’t know about the UTF-8 requirement, I believe this is a recent change, isn’t it?  
I’m using the latest tip.  
It looks like the Jucer saves its files without BOM, why? My WinMerge app is having troubles with this…

---

<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:** [February 5, 2011, 12:38pm UTC](https://forum.juce.com/t/characters-encoding-bug/6367/5 "2011-02-05T12:38:25Z")

</div>

> [@](#):
>
> It looks like the Jucer saves its files without BOM, why?

Because BOMs aren’t portable - some compilers can’t build files that use them. It’s annoying, I know, but in C++ the only truly portable source files can only contain ascii characters below 127, and encode unicode string literals as utf-8 using escape sequences.
