<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change text to Unicode in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594521#M46559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bạn ơi có thể hướng dẫn mình cách sử dụng đoạn code này không mình bị lỗi font chữ trong arcgis nhưng fixx không được&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/452342_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/452343_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Jul 2019 07:53:42 GMT</pubDate>
    <dc:creator>MRC</dc:creator>
    <dc:date>2019-07-04T07:53:42Z</dc:date>
    <item>
      <title>Change text to Unicode</title>
      <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594516#M46554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my problem. I have a bulk of attribute tables with string columns. Those string columns contain text that has been written in Vietnamese font (.vn arial, VNI Windows, VIQR and others). Mostly each attribute table contains only one Font. So now if i open a map it looks like that "di??n tÝch, d©n sè c¸c ®¬n v?? hµnh chÝnh cña thµnh phè" instead of "di??n tích, dân s?? các ???n v?? hành chính c?a". All this different fonts are a big mess and people who didn't install the fonts can not read it. To keep it short the best way is to bring it all to unicode which I d like to do in Python. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I am thinking about is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Step through the attribute table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Read the field value (original Text)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Convert it to Unicode (This I don't know how to)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4) Update the field with the Converted text&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and so on&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anybody out there who can give me a hand on this? Or any other time saving solutions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. For few files i used to do it as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Export the attribute table as a .dbf file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Open it in Excel and copy the whole table into clipboard&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Open a program called UniKey&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4) Pressing ctrl+shift+f6&amp;nbsp; - which converts the text in the clipboard to unicode (u have to define the source and output dataset first)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5) Paste it over the orig dbf table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6) In Arcgis join it with the original table &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7) Use the field calculator to copy the joined table to the original one&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is obviously why i don't want to do that hundred of times.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 05:52:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594516#M46554</guid>
      <dc:creator>chriss_</dc:creator>
      <dc:date>2012-02-02T05:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change text to Unicode</title>
      <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594517#M46555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use the encode() on your string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; a =&amp;nbsp; u"di�?n tÝch, d©n sè c¸c ®¬n v�? hµnh chÝnh cña thµnh phè"
&amp;gt;&amp;gt;&amp;gt; print a.encode('ascii','ignore')
din tch, dn s cc n v hnh chnh ca thnh ph
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;or &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; a =&amp;nbsp; u"di�?n tÝch, d©n sè c¸c ®¬n v�? hµnh chÝnh cña thµnh phè"
&amp;gt;&amp;gt;&amp;gt; print a.encode('ascii','replace')
di?n t?ch, d?n s? c?c ??n v? h?nh ch?nh c?a th?nh ph?
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;or even:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; a =&amp;nbsp; u"di�?n tÝch, d©n sè c¸c ®¬n v�? hµnh chÝnh cña thµnh phè"
&amp;gt;&amp;gt;&amp;gt; print a.encode('ascii', 'xmlcharrefreplace')
di�?n tÝch, d©n sè c¸c ®¬n v�? hµnh chÝnh cña thµnh phè
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also convert the string to base64:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; a =&amp;nbsp; u"di�?n tÝch, d©n sè c¸c ®¬n v�? hµnh chÝnh cña thµnh phè"
&amp;gt;&amp;gt;&amp;gt; a = a.encode('base64')
&amp;gt;&amp;gt;&amp;gt; print a
ZGnDlm4gdMOdY2gsIGTCqW4gc8OoIGPCuGMgwq7CrG4gdsOeIGjCtW5oIGNow51uaCBjw7FhIHRo
wrVuaCBwaMOo
&amp;gt;&amp;gt;&amp;gt; print a.decode('base64')
di�?n tÝch, d©n sè c¸c ®¬n v�? hµnh chÝnh cña thµnh phè
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are some links that will give you some background information:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/library/codecs.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://docs.python.org/library/codecs.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/howto/unicode.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://docs.python.org/howto/unicode.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:31:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594517#M46555</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-12T01:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Change text to Unicode</title>
      <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594519#M46557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;flederfauz,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Same problem here: a list of neighborhood names stored in a Gujarati font that I want to store in a geodatabase with unicode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wish I had a real solution for you within python. I ended up taking my data out of ArcGIS and use a character translator I found for Microsoft Word specifically for Hindi and Gujarati fonts. &lt;/SPAN&gt;&lt;A href="http://gujaratitab.anirdesh.com/"&gt;The translator&lt;/A&gt;&lt;SPAN&gt; is built into a Microsoft Word ribbon and installed via a replication of the default Word template. The translation itself is performed by character-by-character replacement.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, a Gujarati translator isn't going to help you, but it's an indicator that character-by-character replacement might be required, as you suggested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I too would be interested in a functional python-based solution to this problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 10:29:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594519#M46557</guid>
      <dc:creator>MattCohen-Price</dc:creator>
      <dc:date>2012-02-03T10:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Change text to Unicode</title>
      <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594520#M46558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@flederfauz:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The script can run on ArcGIS 10 without problems, and i have update some minor changes for conversion facility. You can run it directly under either ArcCatalog or ArcMap.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2012 04:08:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594520#M46558</guid>
      <dc:creator>LeThanh</dc:creator>
      <dc:date>2012-04-20T04:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Change text to Unicode</title>
      <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594521#M46559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bạn ơi có thể hướng dẫn mình cách sử dụng đoạn code này không mình bị lỗi font chữ trong arcgis nhưng fixx không được&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/452342_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/452343_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jul 2019 07:53:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594521#M46559</guid>
      <dc:creator>MRC</dc:creator>
      <dc:date>2019-07-04T07:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Change text to Unicode</title>
      <link>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594518#M46556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi andrew!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your reply. Unfortunately the commands you sent me do not solve my problem. Vietnamese Script is a kind of awkward coded. So I am not sure if there is a built in solution for this. I just found the following link descriping vn character sets. &lt;/SPAN&gt;&lt;A href="http://vietunicode.sourceforge.net/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://vietunicode.sourceforge.net/&lt;BR /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Most important for me is the TCVN3. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I could do a dictionary and look up every single character and replace it by the corresponding unicode character. However from my feeling I would say that this would slow down my code dramatically and doesn't look like the brightest solution. Besdides I don't know how to step through the characters as some TCVN3 character sets have one other two characters to symbolize 1 unicode character (e.g.â =© but&amp;nbsp; �? = Aµ).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also came across an old script dealing with a similar problem in 9.3. but though i modified it I can not get it to run in arcgis10. I keep getting an error stating 'Result' object has no attribute 'GetOutput'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Simple script for conversion of Vietnamese encoding
import arcpy
from arcpy import env
import os
import string
import csv
arcpy.env.overwriteOutput = True

def Convert(str,s,d):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global _Unicode, _TCVN3, _KhongDau
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = u''
&amp;nbsp;&amp;nbsp;&amp;nbsp; for c in str:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idx = s.find(c)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if idx &amp;gt;= 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = d[idx]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result += c
&amp;nbsp;&amp;nbsp;&amp;nbsp; return result
# Array of characters (Using Tuple instead of List)
_Unicode = (
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?�?�??�??�??�?ª�?Š�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'â�?�?�?�?Đê�?ô�?ơƠưƯ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xe2\xc2\u0103\u0102\u0111\u0110\xea\xca\xf4\xd4\u01a1\u01a0\u01b0\u01af'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??áº?áº?�??�?�?áº?áº?áº?áº?áº?áº?áº?áº?áº?áºªáº?áº?áº?áº?áº?áº?áº?áº?áºµáº?áº?áº?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'áÁà�?ảẢã�?ạẠấẤầẦẩẨẫẪậẬắẮằẰẳẲẵẴặẶ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xe1\xc1\xe0\xc0\u1ea3\u1ea2\xe3\xc3\u1ea1\u1ea0\u1ea5\u1ea4\u1ea7\u1ea6\u1ea9\u1ea8\u1eab\u1eaa\u1ead\u1eac\u1eaf\u1eae\u1eb1\u1eb0\u1eb3\u1eb2\u1eb5\u1eb4\u1eb7\u1eb6'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??áº?áººáº?áº?áº?áº?áº?áº?á??á??á?�?á??á??á??á??á??�??�??�??�?�?á??á??�??�??á??á?Š'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'é�?è�?ẻẺẽẼẹẸếẾề�?�?�?�?�?�?�?íÍì�?�?�?ĩĨ�?�?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xe9\xc9\xe8\xc8\u1ebb\u1eba\u1ebd\u1ebc\u1eb9\u1eb8\u1ebf\u1ebe\u1ec1\u1ec0\u1ec3\u1ec2\u1ec5\u1ec4\u1ec7\u1ec6\xed\xcd\xec\xcc\u1ec9\u1ec8\u0129\u0128\u1ecb\u1eca'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??á??á?Ž�?µ�??á??á?�?á??á??á??á??á??á??á??á??á??á??á??á?šá??á?�?á?Ÿá?žá??á??á??á??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ó�?ò�?ỏ�?õ�?ọ�?�?Ố�?�?�?�?�?�?�?�?�?�?ờ�?�?�?ỡỠợỢ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xf3\xd3\xf2\xd2\u1ecf\u1ece\xf5\xd5\u1ecd\u1ecc\u1ed1\u1ed0\u1ed3\u1ed2\u1ed5\u1ed4\u1ed7\u1ed6\u1ed9\u1ed8\u1edb\u1eda\u1edd\u1edc\u1edf\u1ede\u1ee1\u1ee0\u1ee3\u1ee2'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�?º�?š�??�??á??á??�??�??á??á??á??á??á??á?ªá??á??á??á??á??á??á??á??á??á??á??á??á?µá??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ú�?ù�?ủỦũŨụỤứỨừỪửỬữỮựỰỳỲỷỶỹỸỵỴýÝ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xfa\xda\xf9\xd9\u1ee7\u1ee6\u0169\u0168\u1ee5\u1ee4\u1ee9\u1ee8\u1eeb\u1eea\u1eed\u1eec\u1eef\u1eee\u1ef1\u1ef0\u1ef3\u1ef2\u1ef7\u1ef6\u1ef9\u1ef8\u1ef5\u1ef4\xfd\xdd'
)
_KhongDau = (
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'aAaAdDeEoOoOuU'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'aAaAaAaAaAaAaAaAaAaAaAaAaAaAaA'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'eEeEeEeEeEeEeEeEeEeEiIiIiIiIiI'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoO'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'uUuUuUuUuUuUuUuUuUuUyYyYyYyYyY'
)
_TCVN3= (
&amp;nbsp; #'�??�??�??�??�??�??�?ª�??�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'©¢¨¡®§ª£«¤¬¥*¦'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xa9\xa2\xa8\xa1\xae\xa7\xaa\xa3\xab\xa4\xac\xa5\xad\xa6'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?µ�?µ�??�??�??�??�??�??�?Š�?Š�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'¸¸µµ¶¶··¹¹�?�?�?�?�?�?�?�?�?�?¾¾»»¼¼½½�?�?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xb8\xb8\xb5\xb5\xb6\xb6\xb7\xb7\xb9\xb9\xca\xca\xc7\xc7\xc8\xc8\xc9\xc9\xcb\xcb\xbe\xbe\xbb\xbb\xbc\xbc\xbd\xbd\xc6\xc6'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?�?�?�?�?Ž�?Ž�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�?�?�?�?�?ž�?ž'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ÐÐ�?�?�?�?ÏÏ�?�?�?�?�?�?�?�?�?�?�?�?ÝÝ�?�?�?�?�?�?�?�?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xcf\xcf\xd1\xd1\xd5\xd5\xd2\xd2\xd3\xd3\xd4\xd4\xd6\xd6\xdd\xdd\xd7\xd7\xd8\xd8\xdc\xdc\xde\xde'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?Ÿ�?Ÿ�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�?ª�?ª�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ãã�?�?ááââääèèååææççééííêêëëììîî'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xe2\xe2\xe4\xe4\xe8\xe8\xe5\xe5\xe6\xe6\xe7\xe7\xe9\xe9\xed\xed\xea\xea\xeb\xeb\xec\xec\xee\xee'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??�??�??�??�??�??�??�??�??�?µ�?µ�??�??�??�??�??�??�?º�?º�??�??�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'óóïïññòòôôøøõõöö÷÷ùùúúûûüüþþýý'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xf3\xf3\xef\xef\xf1\xf1\xf2\xf2\xf4\xf4\xf8\xf8\xf5\xf5\xf6\xf6\xf7\xf7\xf9\xf9\xfa\xfa\xfb\xfb\xfc\xfc\xfe\xfe\xfd\xfd'
)

def ConvertEncoding(input_fc,input_fd,newfd,sE,dE):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(input_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.GetCount_management(input_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(result.GetOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetProgressor("step", "Reading", 0, count, 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in iter(rows.next, None):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string1 = row.GetValue(input_fd)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; string1.strip() &amp;lt;&amp;gt; "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newvalue =&amp;nbsp; Convert(row.GetValue(input_fd),sE,dE)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SetValue(newfd,newvalue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SetValue(newfd,"")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetProgressorPosition()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ResetProgressor()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
#Input paramaters&amp;nbsp;&amp;nbsp; 
inputShapefile ="C://Project/TCVN.shp" #arcpy.GetParameterAsText(0)
inputFields = "TCVN"
outputShapefile = "C://Project/UNI.shp"#arcpy.GetParameterAsText(2)
#Processing block
#Copy to new shapefile
arcpy.CopyFeatures_management(inputShapefile, outputShapefile)
# Add new field for storing result
#gp.AddField(outputShapefile,newField,"TEXT","#","#",254)#,"#","NON_NULLABLE","NON_REQUIRED","#")
#Processing conversion of encoding
inputFL = inputFields.split(";")
for inputField in inputFL:
&amp;nbsp;&amp;nbsp;&amp;nbsp; ConvertEncoding(outputShapefile,inputField,inputField,_TCVN3,_Unicode)
arcpy.AddMessage("Finish!")

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;that is the original one&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Simple script for conversion of Vietnamese encoding
import arcgisscripting
gp = arcgisscripting.create(9.3)
def Convert(str,s,d):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global _Unicode, _TCVN3, _KhongDau
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = u''
&amp;nbsp;&amp;nbsp;&amp;nbsp; for c in str:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idx = s.find(c)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if idx &amp;gt;= 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = d[idx]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result += c
&amp;nbsp;&amp;nbsp;&amp;nbsp; return result
# Array of characters (Using Tuple instead of List)
_Unicode = (
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?�?�??�??�??�?ª�?Š�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'â�?�?�?�?Đê�?ô�?ơƠưƯ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xe2\xc2\u0103\u0102\u0111\u0110\xea\xca\xf4\xd4\u01a1\u01a0\u01b0\u01af'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??áº?áº?�??�?�?áº?áº?áº?áº?áº?áº?áº?áº?áº?áºªáº?áº?áº?áº?áº?áº?áº?áº?áºµáº?áº?áº?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'áÁà�?ảẢã�?ạẠấẤầẦẩẨẫẪậẬắẮằẰẳẲẵẴặẶ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xe1\xc1\xe0\xc0\u1ea3\u1ea2\xe3\xc3\u1ea1\u1ea0\u1ea5\u1ea4\u1ea7\u1ea6\u1ea9\u1ea8\u1eab\u1eaa\u1ead\u1eac\u1eaf\u1eae\u1eb1\u1eb0\u1eb3\u1eb2\u1eb5\u1eb4\u1eb7\u1eb6'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??áº?áººáº?áº?áº?áº?áº?áº?á??á??á?�?á??á??á??á??á??�??�??�??�?�?á??á??�??�??á??á?Š'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'é�?è�?ẻẺẽẼẹẸếẾề�?�?�?�?�?�?�?íÍì�?�?�?ĩĨ�?�?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xe9\xc9\xe8\xc8\u1ebb\u1eba\u1ebd\u1ebc\u1eb9\u1eb8\u1ebf\u1ebe\u1ec1\u1ec0\u1ec3\u1ec2\u1ec5\u1ec4\u1ec7\u1ec6\xed\xcd\xec\xcc\u1ec9\u1ec8\u0129\u0128\u1ecb\u1eca'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??á??á?Ž�?µ�??á??á?�?á??á??á??á??á??á??á??á??á??á??á??á?šá??á?�?á?Ÿá?žá??á??á??á??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ó�?ò�?ỏ�?õ�?ọ�?�?Ố�?�?�?�?�?�?�?�?�?�?ờ�?�?�?ỡỠợỢ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xf3\xd3\xf2\xd2\u1ecf\u1ece\xf5\xd5\u1ecd\u1ecc\u1ed1\u1ed0\u1ed3\u1ed2\u1ed5\u1ed4\u1ed7\u1ed6\u1ed9\u1ed8\u1edb\u1eda\u1edd\u1edc\u1edf\u1ede\u1ee1\u1ee0\u1ee3\u1ee2'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�?º�?š�??�??á??á??�??�??á??á??á??á??á??á?ªá??á??á??á??á??á??á??á??á??á??á??á??á?µá??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ú�?ù�?ủỦũŨụỤứỨừỪửỬữỮựỰỳỲỷỶỹỸỵỴýÝ'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xfa\xda\xf9\xd9\u1ee7\u1ee6\u0169\u0168\u1ee5\u1ee4\u1ee9\u1ee8\u1eeb\u1eea\u1eed\u1eec\u1eef\u1eee\u1ef1\u1ef0\u1ef3\u1ef2\u1ef7\u1ef6\u1ef9\u1ef8\u1ef5\u1ef4\xfd\xdd'
)
_KhongDau = (
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'aAaAdDeEoOoOuU'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'aAaAaAaAaAaAaAaAaAaAaAaAaAaAaA'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'eEeEeEeEeEeEeEeEeEeEiIiIiIiIiI'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'oOoOoOoOoOoOoOoOoOoOoOoOoOoOoO'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'uUuUuUuUuUuUuUuUuUuUyYyYyYyYyY'
)
_TCVN3= (
&amp;nbsp; #'�??�??�??�??�??�??�?ª�??�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'©¢¨¡®§ª£«¤¬¥*¦'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xa9\xa2\xa8\xa1\xae\xa7\xaa\xa3\xab\xa4\xac\xa5\xad\xa6'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?µ�?µ�??�??�??�??�??�??�?Š�?Š�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'¸¸µµ¶¶··¹¹�?�?�?�?�?�?�?�?�?�?¾¾»»¼¼½½�?�?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xb8\xb8\xb5\xb5\xb6\xb6\xb7\xb7\xb9\xb9\xca\xca\xc7\xc7\xc8\xc8\xc9\xc9\xcb\xcb\xbe\xbe\xbb\xbb\xbc\xbc\xbd\xbd\xc6\xc6'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?�?�?�?�?Ž�?Ž�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�?�?�?�?�?ž�?ž'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ÐÐ�?�?�?�?ÏÏ�?�?�?�?�?�?�?�?�?�?�?�?ÝÝ�?�?�?�?�?�?�?�?'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #u'\xcf\xcf\xd1\xd1\xd5\xd5\xd2\xd2\xd3\xd3\xd4\xd4\xd6\xd6\xdd\xdd\xd7\xd7\xd8\xd8\xdc\xdc\xde\xde'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�?Ÿ�?Ÿ�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�??�?ª�?ª�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'ãã�?�?ááââääèèååææççééííêêëëììîî'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xe2\xe2\xe4\xe4\xe8\xe8\xe5\xe5\xe6\xe6\xe7\xe7\xe9\xe9\xed\xed\xea\xea\xeb\xeb\xec\xec\xee\xee'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'�??�??�??�??�??�??�??�??�??�??�??�??�?µ�?µ�??�??�??�??�??�??�?º�?º�??�??�??�??�??�??�??�??'
&amp;nbsp;&amp;nbsp;&amp;nbsp; u'óóïïññòòôôøøõõöö÷÷ùùúúûûüüþþýý'
&amp;nbsp;&amp;nbsp;&amp;nbsp; #'\xf3\xf3\xef\xef\xf1\xf1\xf2\xf2\xf4\xf4\xf8\xf8\xf5\xf5\xf6\xf6\xf7\xf7\xf9\xf9\xfa\xfa\xfb\xfb\xfc\xfc\xfe\xfe\xfd\xfd'
)

def ConvertEncoding(input_fc,input_fd,newfd,sE,dE):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = gp.updatecursor(input_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = gp.GetCount_management(input_fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(result.GetOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SetProgressor("step", "Reading", 0, count, 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in iter(rows.next, None):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string1 = row.GetValue(input_fd)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; string1.strip() &amp;lt;&amp;gt; "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newvalue =&amp;nbsp; Convert(row.GetValue(input_fd),sE,dE)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SetValue(newfd,newvalue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SetValue(newfd,"")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SetProgressorPosition()
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.ResetProgressor()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
#Input paramaters&amp;nbsp;&amp;nbsp; 
inputShapefile = gp.GetParameterAsText(0)
inputFields = gp.GetParameterAsText(1)
outputShapefile = gp.GetParameterAsText(2)
#Processing block
gp.toolbox = "management"
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Copy to new shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures_management(inputShapefile,outputShapefile)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add new field for storing result
&amp;nbsp;&amp;nbsp;&amp;nbsp; #gp.AddField(outputShapefile,newField,"TEXT","#","#",254)#,"#","NON_NULLABLE","NON_REQUIRED","#")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Processing conversion of encoding
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputFL = inputFields.split(";")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for inputField in inputFL:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConvertEncoding(outputShapefile,inputField,inputField,_TCVN3,_Unicode)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Finish!")
#Free resources
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.GetMessage(2)
del gp
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:31:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-to-unicode/m-p/594518#M46556</guid>
      <dc:creator>chriss_</dc:creator>
      <dc:date>2021-12-12T01:31:52Z</dc:date>
    </item>
  </channel>
</rss>

