# \[solved\] loadString, system() & Unicode

**URL:** <https://discourse.libcinder.org/t/solved-loadstring-system-unicode/1122>\
**Category:** Using Cinder\
**Created:** [April 4, 2018, 3:53pm UTC](https://discourse.libcinder.org/t/solved-loadstring-system-unicode/1122 "2018-04-04T15:53:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/daniel/32/50_2.png) [@daniel](https://discourse.libcinder.org/u/daniel)\
**Post date:** [April 4, 2018, 3:53pm UTC](https://discourse.libcinder.org/t/solved-loadstring-system-unicode/1122/1 "2018-04-04T15:53:28Z")

</div>

Hello hello,

I’m having a bit of trouble with Utf-8 encoded files. Let’s make it a very simple example:

```
CI_LOG_I(loadString(loadAsset("test.yaml"));

```

And test.yaml:

```
ÄÄää

```

If I save my file as a latin1 variant (i.e. ISO-8869-15) I see the correct output in my Visual Studio Output. If I save it as UTF-8 or UTF-8 with BOM I get something like “Ã„Ã„Ã”. (Tested with vim and Sublime)

Now I’m not too sure how Visual Studio Console Output handles Unicode. So maybe that is the problem. If I make TextBox and use my loaded string it works like a charm either way (fair enough!).

However: I need to pipe my loaded content at some point to system() for some ugly behind-the-scenes font rendering mumbo jumbo. In general system() should be fine with this and don’t care too much about the encoding. I end up getting the very same “Ã„Ã„Ã” rendered though which makes me think that how I (or cinder or c++ or…) handles the encoding might be the problem.

I’d be grateful for any ideas or hints on this, thank you!

// edit:  
So it basically seems that at some point my UTF-8 encoded string is treated as latin-1. For example I get the same kind of characters if I save a html file as unicode and ommit the Content-Type: Charset=Utf-8 header.

// edit2:  
I’m on windows 🙂

---

<div class="post-metadata">

**Author:** ![andrewfb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/andrewfb/32/2_2.png) [@andrewfb](https://discourse.libcinder.org/u/andrewfb)\
**Post date:** [April 5, 2018, 2:59am UTC](https://discourse.libcinder.org/t/solved-loadstring-system-unicode/1122/2 "2018-04-05T02:59:43Z")

</div>

I believe this is actually a bug in Cinder’s `console()` function (which wraps `OutputDebugString()` on MSW). I’ve made a pull request here:

> <https://github.com/cinder/Cinder/pull/1995>

I’d be curious if that addresses your use case as well.

---

<div class="post-metadata">

**Author:** ![daniel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/daniel/32/50_2.png) [@daniel](https://discourse.libcinder.org/u/daniel)\
**Post date:** [April 5, 2018, 8:31am UTC](https://discourse.libcinder.org/t/solved-loadstring-system-unicode/1122/3 "2018-04-05T08:31:00Z")

</div>

Yes! It did indeed and also helped me with my other problem.

To pass on unicoded arguments to a system call I now use this:

```
_wsystem( msw::toWideString(cmd).c_str() );

```

Thank you so much, Andrew.
