When you upgrade your resource strings to Unicode, don’t forget to specify the L prefix

The Old New Thing (Raymond Chen) Tools

Summary

Explains that when using Unicode escape sequences (like \x2019) in Windows resource strings, you must prefix the string with L to make it a wide-character string; otherwise the escape is misinterpreted as an 8-bit sequence.

<p>Some time ago, I discussed how <a title="The Resource Compiler defaults to CP_ACP, even in the face of subtle hints that the file is UTF-8" href="https://devblogs.microsoft.com/oldnewthing/20190607-00/?p=102569"> the Resource Compiler defaults to CP_ACP, even in the face of subtle hints that the file is UTF-8</a>.</p> <p>After yet another incident of <a title="Making sure the Microsoft Visual C++ compiler chooses the right source encoding" href="https://devblogs.microsoft.com/oldnewthing/20241231-00/?p=110696"> Visual Studio secretly changing the file encoding from 1252 to UTF-8</a> and breaking all non-ASCII strings, combined with <a title="How various git diff viewers represent file encoding changes in pull requests" href="https://devblogs.microsoft.com/oldnewthing/20241230-00/?p=110692"> Azure DevOps and Visual Studio simply ignoring encoding changes when showing diffs</a>, a colleague decided to solve the problem once and for all by using explicit Unicode escapes <tt>\x####</tt> to represent non-ASCII characters. That way, it doesn&#8217;t matter whether the file encoding is 1252 or UTF-8 because the two code pages agree on the common ASCII subset.</p> <p>What used to be</p> <pre>IDS_AWESOME "That’s great!" </pre> <p>was changed to</p> <pre>IDS_AWESOME "That\x2019s great!" </pre> <p>Unfortunately, the resulting string that appeared on screen was</p> <blockquote class="q"><p>That 19s great!</p></blockquote> <p>What went wrong?</p> <p>If you are encoding Unicode into your string, you have to put an <code>L</code> prefix on the quoted string. Otherwise, the <tt>\xABCD</tt> sequence is interpreted as an 8-bit <tt>\xAB</tt> escape sequence, followed by two literal characters <tt>CD</tt>. In this case, the <tt>\x2019</tt> was interpreted as <tt>\x20</tt> (which encodes a space) followed by the literal characters <tt>19</tt>, resulting in the string <tt>That␣19s great!</tt>.</p> <p>The correct conversion includes the <code>L</code> prefix.</p> <pre>IDS_AWESOME <span style="border: solid 1px currentcolor;">L</span>"That\x2019s great!" </pre> <p>The post <a href="https://devblogs.microsoft.com/oldnewthing/20260507-00/?p=112307">When you upgrade your resource strings to Unicode, don&#8217;t forget to specify the L prefix</a> appeared first on <a href="https://devblogs.microsoft.com/oldnewthing">The Old New Thing</a>.</p>
Original Article
View Cached Full Text

Cached at: 05/16/26, 03:32 AM

# When you upgrade your resource strings to Unicode, don't forget to specify the L prefix - The Old New Thing Source: [https://devblogs.microsoft.com/oldnewthing/20260507-00?p=112307](https://devblogs.microsoft.com/oldnewthing/20260507-00?p=112307) May 7th, 2026 ![like](https://devblogs.microsoft.com/oldnewthing/wp-content/themes/devblogs-evo/images/emojis/like.svg)![mind blown](https://devblogs.microsoft.com/oldnewthing/wp-content/themes/devblogs-evo/images/emojis/mind-blown.svg)3 reactions ![](https://devblogs.microsoft.com/oldnewthing/wp-content/uploads/sites/38/2019/02/RaymondChen_5in-150x150.jpg) Some time ago, I discussed how[the Resource Compiler defaults to CP\_ACP, even in the face of subtle hints that the file is UTF\-8](https://devblogs.microsoft.com/oldnewthing/20190607-00/?p=102569)\. After yet another incident of[Visual Studio secretly changing the file encoding from 1252 to UTF\-8](https://devblogs.microsoft.com/oldnewthing/20241231-00/?p=110696)and breaking all non\-ASCII strings, combined with[Azure DevOps and Visual Studio simply ignoring encoding changes when showing diffs](https://devblogs.microsoft.com/oldnewthing/20241230-00/?p=110692), a colleague decided to solve the problem once and for all by using explicit Unicode escapes\\x\#\#\#\#to represent non\-ASCII characters\. That way, it doesn’t matter whether the file encoding is 1252 or UTF\-8 because the two code pages agree on the common ASCII subset\. What used to be ``` IDS_AWESOME "That’s great!" ``` was changed to ``` IDS_AWESOME "That\x2019s great!" ``` Unfortunately, the resulting string that appeared on screen was > That 19s great\! What went wrong? If you are encoding Unicode into your string, you have to put an`L`prefix on the quoted string\. Otherwise, the\\xABCDsequence is interpreted as an 8\-bit\\xABescape sequence, followed by two literal charactersCD\. In this case, the\\x2019was interpreted as\\x20\(which encodes a space\) followed by the literal characters19, resulting in the stringThat␣19s great\!\. The correct conversion includes the`L`prefix\. ``` IDS_AWESOME L"That\x2019s great!" ``` ### Category ### Topics ## Author ![Raymond Chen](https://devblogs.microsoft.com/oldnewthing/wp-content/uploads/sites/38/2019/02/RaymondChen_5in-150x150.jpg) Raymond has been involved in the evolution of Windows for more than 30 years\. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie\-jeebies\. The Web site spawned a book, coincidentally also titled The Old New Thing \(Addison Wesley 2007\)\. He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information\. ## Read next ## Stay informed Get notified when new posts are published\. Follow this blog - [https://twitter.com/ChenCravat](https://twitter.com/ChenCravat) - [![youtube](https://devblogs.microsoft.com/oldnewthing/wp-content/themes/devblogs-evo/images/social-icons/youtube.svg)](https://www.youtube.com/playlist?list=PLlrxD0HtieHge3_8Dm48C0Ns61I6bHThc) - [https://github.com/oldnewthing](https://github.com/oldnewthing) - [https://devblogs.microsoft.com/oldnewthing/feed/](https://devblogs.microsoft.com/oldnewthing/feed/)

Similar Articles

Equivalence of Unicode strings is strange (2016)

Lobsters Hottest

Unicode string equivalence is complex, especially with collations, leading to surprising results like deletion of control characters and non-deterministic grouping. The author discusses challenges in implementing proper Unicode support in database systems.

Unicode composition for filenames

Lobsters Hottest

This document discusses the challenges of Unicode filename composition (NFC vs NFD) across different operating systems in the context of the Subversion version control system, and proposes solutions for handling these differences.

Beyond Perplexity: UTF-8 Validity in Byte-aware Language Models

arXiv cs.CL

This paper investigates the relationship between training scale and UTF-8 generation reliability in byte-level language models, finding that UTF-8 validity convergence lags behind perplexity by roughly a factor of two. The authors introduce evaluation protocols to isolate structural validity and show that reliable UTF-8 generation is a distinct capability requiring separate evaluation.