filegdb api - "UPPER" in sql query not working for Cyrrilic symbols

3749
5
06-05-2016 03:08 AM
OlegMaslenko
New Contributor


     Hi everybody. Do not scold for my English.

I'm using filegdb api v1.4. and have such problem with sql query.

SQL query for example: "SELECT * FROM City WHERE UPPER(TITLE_ENG) LIKE '%KIEV%' " - this is work

SQL query for example: "SELECT * FROM City WHERE UPPER(TITLE_RU) LIKE '%КИЕВ%' " - this isn't work.

     I noticed:

1) that function "UPPER" and "LOWER" won't work with the text contains Cyrrilic symbols. I tried to use "collate" but it didn't work.

2) that SQL query works in ArcMap

     Are anybody knows how to decide this problem with Cyrillic symbols!

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

Interesting problem... a lot of the web links suggest converting to Unicode first prior to using upper or lower, however, I don't know about sql, but see this python example

0 Kudos
OlegMaslenko
New Contributor

and where it is (python example)?

0 Kudos
DanPatterson_Retired
MVP Emeritus

search using    python upper unicode  for example, yields many threads and links eg.

http://stackoverflow.com/questions/727507/how-can-i-convert-unicode-to-uppercase-to-print-it

0 Kudos
OlegMaslenko
New Contributor

I think this method should not help! The word which must be founded I can do anything, but ho do like that

"SEARCH * FROM CITY WHERE UPPER(Encoding.UNICODE(TITLE)) = UPPER("SEARCHED_TEXT")"

0 Kudos
DanPatterson_Retired
MVP Emeritus

well, I am not worried about the query now, since that is the end goal, and not the root of the problem.

I will leave this for others to ponder so they can answer your question directly

Pay attention to the equality checks and the type tests

>>> a = "КИЕВ"
>>> b = a.decode('utf-8')
>>> type(a)
<type 'str'>
>>> type(b)
<type 'unicode'>
>>> print(a)
КИЕВ
>>> print(b)
КИЕВ
>>> a == b # ?????
True
>>> c = "KIEV"
>>> type(c)
<type 'str'>
>>> a == c # ?????
False
>>> b == c # ??????
False

good luck