<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Neo’s Substack]]></title><description><![CDATA[My personal Substack]]></description><link>https://neo.kn</link><image><url>https://substackcdn.com/image/fetch/$s_!jCY2!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F262c08cc-be44-43c9-8c6c-2aa270dc9d9b_144x144.png</url><title>Neo’s Substack</title><link>https://neo.kn</link></image><generator>Substack</generator><lastBuildDate>Wed, 06 May 2026 10:43:34 GMT</lastBuildDate><atom:link href="https://neo.kn/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Neo Kusanagi]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[neokn@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[neokn@substack.com]]></itunes:email><itunes:name><![CDATA[Neo Kusanagi]]></itunes:name></itunes:owner><itunes:author><![CDATA[Neo Kusanagi]]></itunes:author><googleplay:owner><![CDATA[neokn@substack.com]]></googleplay:owner><googleplay:email><![CDATA[neokn@substack.com]]></googleplay:email><googleplay:author><![CDATA[Neo Kusanagi]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Remove Diacritics in String with C#]]></title><description><![CDATA[0x00 Introduction]]></description><link>https://neo.kn/p/remove-diacritics-in-string-with</link><guid isPermaLink="false">https://neo.kn/p/remove-diacritics-in-string-with</guid><dc:creator><![CDATA[Neo Kusanagi]]></dc:creator><pubDate>Tue, 13 Aug 2024 02:09:27 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jCY2!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F262c08cc-be44-43c9-8c6c-2aa270dc9d9b_144x144.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div><hr></div><h3>0x00 Introduction</h3><p>Recently, I&#8217;ve been exploring the transition of a WebApi to GraphQL and decided to use the HotChocolate package for GraphQL schema document. However, I encountered a perplexing error message:</p><pre><code>HotChocolate.SchemaException: For more details look at the `Errors` property. The specified name is not a valid GraphQL name. (Parameter &#8216;value&#8217;) (HotChocolate.Types.EnumType&lt;MyEnum&gt;)&#8221;. Initially, I assumed that converting Enum values to string would be as simple as calling ToString(). But, to my surprise, an error occurred. Let&#8217;s dig into the issue and how we fixed it</code></pre><div><hr></div><h3>0x01 Trouble&nbsp;Shooting</h3><p>The codebase includes a substantial Enum with brand names, and at first glance, everything seemed fine.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://neo.kn/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Neo&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>However, after setting breakpoints and inspecting the code, I identified an Enum value containing a diacritic character.</p><p>Here&#8217;s an example:</p><pre><code>enum Brand 
{
 // &#8230;
 Herm&#232;s,
 // &#8230;
}</code></pre><p>When Herm&#232;s was converted to a GraphQL Enum Type using ToString(), it violated the GraphQL naming conventions, leading to the error.</p><div><hr></div><h3>0x02 Fix&nbsp;It</h3><p>The straightforward approach would be to create a mapping table and replace diacritic characters with their corresponding ASCII letters.</p><p>However, this solution lacks elegance.</p><p>While searching for alternatives, I discovered that Unicode has four different normalization forms (Normalization Form, abbreviated as NFC, NFD, NFKC, NFKD).</p><p>Ref:<br>1.&nbsp;<a href="https://learn.microsoft.com/en-us/dotnet/api/system.text.normalizationform">.NET NormalizationForm Enum</a><br>2.&nbsp;<a href="https://unicode.org/reports/tr15/">UNICODE NORMALIZATION FORMS</a></p><p>For our purposes, NFC and NFD are relevant normalization forms to handle diacritics. To implement a cleaner solution, we can use the&nbsp;<em><strong>CharUnicodeInfo.GetUnicodeCategory</strong></em>&nbsp;method to identify characters that require removal.</p><pre><code>static string RemoveDiacritics(string s) 
{
 return string.Concat(s.Normalize(NormalizationForm.FormD).Where(c =&gt; CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)).Normalize(NormalizationForm.FormC);
}</code></pre><p>This method effectively removes diacritics, making the code more readable and easier to maintain.</p><div><hr></div><h3>0x03 Unicode ASCII Folding&nbsp;Filter</h3><p>Another option, the&nbsp;<a href="http://svn.apache.org/repos/asf/lucene/java/tags/lucene_solr_4_5_1/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/ASCIIFoldingFilter.java">ASCII Folding Filter</a>, involves using a large switch-case construct.</p><p>However, it&#8217;s worth noting that this filter handles more than just diacritics; it deals with all types of Unicode characters.</p><blockquote><p>This class converts alphabetic, numeric, and symbolic Unicode characters which are not in the first 127 ASCII characters (the &#8220;Basic Latin&#8221; Unicode block) into their ASCII equivalents, if one exists.&#8202;&#8212;&#8202;from the source code comment</p></blockquote><p>This might be suitable if you need to process text, such as articles or user input, and convert it into a system that only allows ASCII characters.</p><div><hr></div><h3>0xFF Conclusion</h3><p>The bug occurred during the creation of the Enum, where copying and pasting from a data source (in this case, a European company) led to names containing diacritics.</p><p>As most programming languages support Unicode, pasting such names typically doesn&#8217;t cause issues.</p><p>Interestingly, in some languages like Swift, you can even use emojis to write code</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tTqY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tTqY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 424w, https://substackcdn.com/image/fetch/$s_!tTqY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 848w, https://substackcdn.com/image/fetch/$s_!tTqY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 1272w, https://substackcdn.com/image/fetch/$s_!tTqY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tTqY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png" width="800" height="226" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71abf829-e067-4296-98fb-0128954d7214_800x226.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:226,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tTqY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 424w, https://substackcdn.com/image/fetch/$s_!tTqY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 848w, https://substackcdn.com/image/fetch/$s_!tTqY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 1272w, https://substackcdn.com/image/fetch/$s_!tTqY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71abf829-e067-4296-98fb-0128954d7214_800x226.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Naming-Constants-and-Variables">https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Naming-Constants-and-Variables</a></figcaption></figure></div><p>But in C#, using emojis or Unicode symbols (e.g., &#9312;) directly within enums won&#8217;t work due to naming restrictions.</p><blockquote><p><a href="https://github.com/dotnet/csharplang/discussions/3490">[Proposal] Support emoji for variable name</a></p></blockquote><p>With proper handling of diacritics and Unicode characters, you can ensure your GraphQL implementation works smoothly, making it easier for developers to work with your APIs.</p><div class="captioned-button-wrap" data-attrs="{&quot;url&quot;:&quot;https://substack.com/refer/neokusanagi?utm_source=substack&amp;utm_context=post&amp;utm_content=147647877&amp;utm_campaign=writer_referral_button&quot;,&quot;text&quot;:&quot;Start a Substack&quot;}" data-component-name="CaptionedButtonToDOM"><div class="preamble"><p class="cta-caption">Start writing today. Use the button below to create a Substack of your own</p></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://substack.com/refer/neokusanagi?utm_source=substack&amp;utm_context=post&amp;utm_content=147647877&amp;utm_campaign=writer_referral_button&quot;,&quot;text&quot;:&quot;Start a Substack&quot;,&quot;hasDynamicSubstitutions&quot;:false}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://substack.com/refer/neokusanagi?utm_source=substack&amp;utm_context=post&amp;utm_content=147647877&amp;utm_campaign=writer_referral_button"><span>Start a Substack</span></a></p></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://neo.kn/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Neo&#8217;s Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Coming soon]]></title><description><![CDATA[This is Neo&#8217;s Substack.]]></description><link>https://neo.kn/p/coming-soon</link><guid isPermaLink="false">https://neo.kn/p/coming-soon</guid><dc:creator><![CDATA[Neo Kusanagi]]></dc:creator><pubDate>Tue, 13 Aug 2024 01:23:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jCY2!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F262c08cc-be44-43c9-8c6c-2aa270dc9d9b_144x144.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is Neo&#8217;s Substack.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://neo.kn/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://neo.kn/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item></channel></rss>