{"id":32,"date":"2015-08-16T04:08:01","date_gmt":"2015-08-16T04:08:01","guid":{"rendered":"http:\/\/128.199.128.224\/wheres-my-lecon\/"},"modified":"2017-10-05T07:45:34","modified_gmt":"2017-10-04T22:45:34","slug":"wheres-my-lecon","status":"publish","type":"post","link":"https:\/\/naganashi.com\/kanjiflow\/wheres-my-lecon\/","title":{"rendered":"Where\u2019s my le\u00e7on?"},"content":{"rendered":"<p>A user reported that he inadvertently overwrote one of his documents because he accidentally used the same name when creating a new lesson.<\/p>\n<p>He was wondering why there wasn\u2019t some sort of warning to prevent this.<\/p>\n<p>I clearly remember writing quite a bit of code in order to stop this very scenario from occurring so I did some investigating to find out what the problem was.<\/p>\n<p>I noticed that the user was using document names that had special unicode characters (in this case a\u00a0\u2018\u00e7\u2019) so I checked the documentation to see if there was anything mentioned. \u00a0I use the standard <code>isEqualToString:<\/code> method to compare strings which does indeed clearly state:<\/p>\n<blockquote><p>The comparison uses the canonical representation of strings, which for a particular string is the length of the string plus the Unicode characters that make up the string. When this method compares two strings, if the individual Unicodes are the same, then the strings are equal, regardless of the backing store. \u201cLiteral\u201d when applied to string comparison means that various Unicode decomposition rules are not applied and Unicode characters are individually compared. <strong>So, for instance, \u201c\u00d6\u201d represented as the composed character sequence \u201cO\u201d and umlaut would not compare equal to \u201c\u00d6\u201d represented as one Unicode character.<\/strong><\/p><\/blockquote>\n<p>Whoops! \u00a0I\u2019ve switched over to using <code>localizedCompare:<\/code> so you can expect the app to properly check document names from version 2.2.6:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"799\" data-permalink=\"https:\/\/naganashi.com\/kanjiflow\/wheres-my-lecon\/lecon-1\/\" data-orig-file=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-1.png\" data-orig-size=\"640,960\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lecon-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-1.png\" class=\"aligncenter size-full wp-image-799\" src=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-1.png\" alt=\"\" width=\"640\" height=\"960\" srcset=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-1.png 640w, https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-1-200x300.png 200w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>It\u2019ll also check when renaming documents:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"798\" data-permalink=\"https:\/\/naganashi.com\/kanjiflow\/wheres-my-lecon\/lecon-2\/\" data-orig-file=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-2.png\" data-orig-size=\"640,960\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lecon-2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-2.png\" class=\"aligncenter size-full wp-image-798\" src=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-2.png\" alt=\"\" width=\"640\" height=\"960\" srcset=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-2.png 640w, https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/lecon-2-200x300.png 200w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>I\u2019m really sorry for any trouble this may have caused anyone and I\u2019m greatly appreciative of the user that reported the issue.<\/p>\n<p>Please do continue letting me know if you notice any strange behavior and I\u2019ll continue improving things.<\/p>\n<p><strong>Happy studies!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A user reported that he inadvertently overwrote one of his documents because he accidentally used the same name when creating a new lesson. He was wondering why there wasn\u2019t some sort of warning to prevent this. I clearly remember writing quite a bit of code in order to stop this very scenario from occurring so &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/naganashi.com\/kanjiflow\/wheres-my-lecon\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Where\u2019s my le\u00e7on?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[11,47],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-blog","tag-bug","tag-new-lesson"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8yq3B-w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":1,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":839,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts\/32\/revisions\/839"}],"wp:attachment":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}