stringr:: functions drops or ignores locale
<p>I am stuggeling with R and stringr. When performing str_trim, str_upper etc my danish characters are converted into unicode charaters:</p>

<pre><code>library(stringr)
library(stringi)

Clean_String &lt;- function(string) {
    #locale &lt;- stri_locale_list()[grep("DK", stri_locale_list())]
    print(c("1:", string))
    string &lt;- stringr::str_trim(string)
    print(c("2:", string))
    string &lt;- stringr::str_to_upper(string, "da_DK")
    print(c("3:", string))
    return(string)
}

Clean_String("This IS a test with danish letters: ÆØÅ ..  ")
</code></pre>

<p>Calling Clean_String gives the following output:</p>

<pre><code>[1] "1:" "This IS a test with danish letters: ÆØÅ ..  "
[1] "2:" "This IS a test with danish letters: ’\u009d\u008f .."
[1] "3:" "THIS IS A TEST WITH DANISH LETTERS: ’\u009d\u008f .."
[1] "THIS IS A TEST WITH DANISH LETTERS: ’\u009d\u008f .."
&gt; 
</code></pre>

<p>So i fails from line "2:". Applying the locale "da_DK" does not have an impact. I think I must be missing something obvious as all stringr:: functions has the same behavior.</p>

<p>I know I can use toupper. toupper keeps the locale. But I would like to use stringr functions and understand what i am doing wrong.</p>

<p>How do I keep the same locale/format on strings?</p>

<p><strong>[UPDATE]</strong>
Seems like the issue was connected to R Tools for Visual Studio 0.4.20623.1711. I needed to specify "Code page" under R Tools->Options->Advanced->Code Page. It was set to (OS Default). Changing it to Western European (ISO) fixed it.</p>