Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8793209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:05:38+00:00 2026-06-13T23:05:38+00:00

It looks like postgres upper/lower function does not handle select characters in Turkish character

  • 0

It looks like postgres upper/lower function does not handle select characters in Turkish character set.

select upper('Aaı'), lower('Aaİ') from mytable;

returns :

AAı, aaİ

instead of :

AAI, aai

Note that normal english characters are converted correctly, but not the Turkish I (lower or upper)

Postgres version: 9.2 32 bit

Database encoding (Same result in any of these): UTF-8, WIN1254, C

Client encoding:

 UTF-8, WIN1254, C

OS: Windows 7 enterprise edition 64bit

SQL functions lower and upper return the following same bytes for ı and İ on UTF-8 encoded database

\xc4b1    
\xc4b0   

And the following on WIN1254 (Turkish) encoded database

\xfd      
\xdd     

I hope my investigation is wrong, and there is something I missed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:05:39+00:00Added an answer on June 13, 2026 at 11:05 pm

    Your problem is 100% Windows. (Or rather Microsoft Visual Studio, which PostgreSQL was built with, to be more precise.)

    For the record, SQL UPPER ends up calling Windows’ LCMapStringW (via towupper via str_toupper) with almost all the right parameters (locale 1055 Turkish for a UTF-8-encoded, Turkish_Turkey database),

    but

    the Visual Studio Runtime (towupper) does not set the LCMAP_LINGUISTIC_CASING bit in LCMapStringW‘s dwMapFlags. (I can confirm that setting it does the trick.) This is not considered a bug at Microsoft; it is by design, and will probably not ever be “fixed” (oh the joys of legacy.)

    You have three ways out of this:

    • implement @Sorrow’s wrapper solution (or write your own native function replacement (DLL).)
    • run your PostgreSQL instance on e.g. Ubuntu which exhibits the right behaviour for Turkic locales (@Sorrow confirmed that it works for him); this is probably the simplest and cleanest way out.
    • drop in a patched 32-bit MSVCR100.DLL in your PostgreSQL bin directory (but although UPPER and LOWER would work, other things such as collation may continue to fail — again, at the Windows level. YMMV.)

    For completeness (and nostalgic fun) ONLY, here is the procedure to patch a Windows system (but remember, unless you’ll be managing this PostgreSQL instance from cradle to grave you may cause a lot of grief to your successor(s); whenever deploying a new test or backup system from scratch you or your successor(s) would have to remember to apply the patch again — and if let’s say you one day upgrade to PostgreSQL 10, which say uses MSVCR120.DLL instead of MSVCR100.DLL, then you’ll have to try your luck with patching the new DLL, too.) On a test system

    • use HxD to open C:\WINDOWS\SYSTEM32\MSVCR100.DLL
    • save the DLL right away with the same name under you PostgreSQL bin directory (do not attempt to copy the file using Explorer or the command line, they might copy the 64bit version)
    • with the file still open in HxD, go to Search > Replace, pick Datatype: Hexvalues, then
      • search for…… 4E 14 33 DB 3B CB 0F 84 41 12 00 00 B8 00 01 00 00
      • replace with… 4E 14 33 DB 3B CB 0F 84 41 12 00 00 B8 00 01 00 01
      • …then once more…
      • search for…… FC 51 6A 01 8D 4D 08 51 68 00 02 00 00 50 E8 E2
      • replace with… FC 51 6A 01 8D 4D 08 51 68 00 02 00 01 50 E8 E2
    • …and re-save under the PostgreSQL bin directory, then restart PostgreSQL and re-run your query.
      • if your query still does not work (make sure your database is UTF-8 encoded with Turkish_Turkey for both LC_CTYPE and LC_COLLATE) open postgres.exe in 32-bit Dependency Walker and make sure it indicates it loads MSVCR100.DLL from the PostgreSQL bin directory.
      • if all functions well copy the patched DLL to the production PostgreSQL bin directory and restart.

    BUT REMEMBER, the moment you move the data off the Ubuntu system or off the patched Windows system to an unpatched Windows system you will have the problem again, and you may be unable to import this data back on Ubuntu if the Windows instance introduced duplicates in a citext field or in a UPPER/LOWER-based function index.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looks like XSD.exe is not delivered as a part of Visual Studio 2010. what
I'm trying to do something like this in Progress SQL (THIS IS NOT POSTGRES!)
I've been having problems yesterday with Heroku shared Postgres DB. It looks like my
Looks like this question has been asked thousand times already, but each person's configuration
Looks like while( condition ) { //do stuff } is completely equivalent to for(
Looks like ExpressionTrees compiler should be near with the C# spec in many behaviors,
Looks like there is no Load event for usercontrol on the CF. I'm used
Looks like dynamic memory allocation without garbage collection is a way to disaster. Dangling
Looks like operator new and operator new[] have exactly the same signature: void* operator
Looks like the options are Propel, Doctrine, and ActiveRecord, others?, but I am only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.