{"id":6563,"date":"2026-04-30T10:37:02","date_gmt":"2026-04-30T09:37:02","guid":{"rendered":"https:\/\/gdksoftware.com\/?page_id=6563"},"modified":"2026-04-30T10:41:55","modified_gmt":"2026-04-30T09:41:55","slug":"moving-from-ansistring-to-unicodestring-in-delphi","status":"publish","type":"page","link":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi","title":{"rendered":"Moving from AnsiString to UnicodeString in Delphi"},"content":{"rendered":"<p><strong>If your organization is running a Delphi application <a href=\"https:\/\/gdksoftware.com\/knowledgebase\/delphi-versions\">developed in version 2007 or older<\/a>, you are sitting on a &#8220;Pre-Unicode&#8221; codebase. In 2009, <a href=\"https:\/\/www.embarcadero.com\/\" target=\"_blank\">Embarcadero<\/a> introduced a fundamental change that redefined the very fabric of the Delphi language: the switch from AnsiString to UnicodeString as the default string type.<\/strong><\/p>\n<p>While this change was necessary to support global character sets and modern Windows APIs, it remains the single biggest technical hurdle in legacy migration.<\/p>\n<h3>Why the Shift is More Than &#8220;Just a Recompile&#8221;<\/h3>\n<p>Before Delphi 2009, a string was essentially a Byte array where one character equaled one byte. In the Unicode world, a string (now WideString\/UnicodeString) uses UTF-16 encoding, where a character typically occupies two bytes.<\/p>\n<p>This shift impacts your code in three critical areas:<\/p>\n<h4>1. Pointer Arithmetic and Buffer Sizes<\/h4>\n<p>If your code calculates buffer sizes based on string length (e.g., <code class=\"\" data-line=\"\">Length(MyString)<\/code>), it may now be off by a factor of two. Hardcoded logic that assumes <code class=\"\" data-line=\"\">SizeOf(Char) = 1<\/code> will result in memory corruption or &#8220;buffer overflows&#8221; because, in modern Delphi, <code class=\"\" data-line=\"\">SizeOf(Char)<\/code> is 2.<\/p>\n<h4>2. Windows API Calls<\/h4>\n<p>Legacy applications often call Windows API functions (like <code class=\"\" data-line=\"\">SendMessage<\/code> or <code class=\"\" data-line=\"\">GetWindowText<\/code>). Older code specifically targeted the &#8220;A&#8221; (Ansi) versions of these functions. To maintain compatibility and performance, these should be updated to the &#8220;W&#8221; (Wide\/Unicode) variants, or the underlying data handling must be carefully marshaled.<\/p>\n<h4>3. Data Integrity and External Integrations<\/h4>\n<p>When your application communicates with external DLLs, file streams, or older databases, it expects a specific byte-stream format. If you send a 2-byte Unicode string to a system expecting a 1-byte Ansi string, you won&#8217;t just get weird characters (like &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Mojibake\">mojibake<\/a>&#8220;), but you risk crashing the integration or corrupting the database entirely.<\/p>\n<h3>The Danger of Manual Conversion<\/h3>\n<p>The risk of a manual conversion is &#8220;silent failure.&#8221; Your application might compile successfully, but it could fail at runtime when a user enters a special character or when a specific file is processed. Auditing millions of lines of code for <code class=\"\" data-line=\"\">SizeOf<\/code> errors or incorrect pointer math is a monumental task that often takes months and carries a high risk of human error.<\/p>\n<h3>The GDK Approach: Precision Through Automation<\/h3>\n<p>At GDK Software, we have refined a methodology to navigate the Unicode minefield without the manual headache. We don&#8217;t just &#8220;find and replace&#8221;; we use a data-driven approach to ensure structural integrity.<\/p>\n<p>Our <a href=\"https:\/\/gdksoftware.com\/delphi-migration-tool\" target=\"_blank\">GDK Duster tool<\/a> is specifically programmed to recognize patterns that indicate Unicode risks. Duster scans the codebase for risky patterns, such as pointer arithmetic on strings, <code class=\"\" data-line=\"\">Move()<\/code> operations, and legacy API calls. Instead of a developer having to manually investigate every string usage, Duster applies proven solutions from our extensive database to refactor the code to be Unicode-compliant.<\/p>\n<p>As recently announced, this automated approach is now available for C++Builder projects as well. We use the C++ compiler to catch errors and apply our &#8220;solution database&#8221; to bridge the gap between Borland C++ 4\/5\/6 and the modern Embarcadero environment.<\/p>\n<h3>Secure Your Data, Modernize Your Code<\/h3>\n<p>The transition from Ansi to Unicode is the most &#8220;dangerous&#8221; part of a Delphi upgrade, but it is also the most rewarding. It opens the door to modern web services, internationalization, and 64-bit performance.<\/p>\n<p>Don&#8217;t let the fear of corrupted data hold your software back. Let GDK Software provide the roadmap and the tools to make your transition seamless.<\/p>\n<h3>Ready to modernize?<\/h3>\n<p>Explore our Delphi Upgrade Services or see how we upgrade legacy Borland C++ applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If your organization is running a Delphi application developed in version 2007 or older, you are sitting on a &#8220;Pre-Unicode&#8221; codebase. In 2009, Embarcadero introduced a fundamental change that redefined the very fabric of the Delphi language: the switch from AnsiString to UnicodeString as the default string type. While this change was necessary to support [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-6563","page","type-page","status-publish","hentry"],"acf":{"type_hero":"img","hero_image":6566,"hero_image_position":"","hero_title":"Moving from AnsiString to UnicodeString in Delphi","hero_content":"","hero_link":null,"hero_show_h1":false,"flexible_content":null},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Moving from AnsiString to UnicodeString in Delphi - GDK Software<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Moving from AnsiString to UnicodeString in Delphi\" \/>\n<meta property=\"og:description\" content=\"If your organization is running a Delphi application developed in version 2007 or older, you are sitting on a &#8220;Pre-Unicode&#8221; codebase. In 2009, Embarcadero introduced a fundamental change that redefined the very fabric of the Delphi language: the switch from AnsiString to UnicodeString as the default string type. While this change was necessary to support [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi\" \/>\n<meta property=\"og:site_name\" content=\"GDK Software\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-30T09:41:55+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschatte leestijd\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/nl\\\/moving-from-ansistring-to-unicodestring-in-delphi\",\"url\":\"https:\\\/\\\/gdksoftware.com\\\/nl\\\/moving-from-ansistring-to-unicodestring-in-delphi\",\"name\":\"Moving from AnsiString to UnicodeString in Delphi - GDK Software\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/nl#website\"},\"datePublished\":\"2026-04-30T09:37:02+00:00\",\"dateModified\":\"2026-04-30T09:41:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/nl\\\/moving-from-ansistring-to-unicodestring-in-delphi#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gdksoftware.com\\\/nl\\\/moving-from-ansistring-to-unicodestring-in-delphi\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/nl\\\/moving-from-ansistring-to-unicodestring-in-delphi#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gdksoftware.com\\\/nl\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Moving from AnsiString to UnicodeString in Delphi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/nl#website\",\"url\":\"https:\\\/\\\/gdksoftware.com\\\/nl\",\"name\":\"GDK Software\",\"description\":\"Zet de stip op je horizon\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gdksoftware.com\\\/nl?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Moving from AnsiString to UnicodeString in Delphi - GDK Software","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi","og_locale":"nl_NL","og_type":"article","og_title":"Moving from AnsiString to UnicodeString in Delphi","og_description":"If your organization is running a Delphi application developed in version 2007 or older, you are sitting on a &#8220;Pre-Unicode&#8221; codebase. In 2009, Embarcadero introduced a fundamental change that redefined the very fabric of the Delphi language: the switch from AnsiString to UnicodeString as the default string type. While this change was necessary to support [&hellip;]","og_url":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi","og_site_name":"GDK Software","article_modified_time":"2026-04-30T09:41:55+00:00","twitter_card":"summary_large_image","twitter_misc":{"Geschatte leestijd":"4 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi","url":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi","name":"Moving from AnsiString to UnicodeString in Delphi - GDK Software","isPartOf":{"@id":"https:\/\/gdksoftware.com\/nl#website"},"datePublished":"2026-04-30T09:37:02+00:00","dateModified":"2026-04-30T09:41:55+00:00","breadcrumb":{"@id":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gdksoftware.com\/nl\/moving-from-ansistring-to-unicodestring-in-delphi#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gdksoftware.com\/nl"},{"@type":"ListItem","position":2,"name":"Moving from AnsiString to UnicodeString in Delphi"}]},{"@type":"WebSite","@id":"https:\/\/gdksoftware.com\/nl#website","url":"https:\/\/gdksoftware.com\/nl","name":"GDK Software","description":"Zet de stip op je horizon","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gdksoftware.com\/nl?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"}]}},"_links":{"self":[{"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/pages\/6563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/comments?post=6563"}],"version-history":[{"count":5,"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/pages\/6563\/revisions"}],"predecessor-version":[{"id":6573,"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/pages\/6563\/revisions\/6573"}],"wp:attachment":[{"href":"https:\/\/gdksoftware.com\/nl\/wp-json\/wp\/v2\/media?parent=6563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}