Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. unicode case insensative compares

unicode case insensative compares

Scheduled Pinned Locked Moved C / C++ / MFC
questionjson
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Henry miller
    wrote on last edited by
    #1

    Is there an easy way to compare two unicode strings that isn't case sensative. That is "fIlEnAmE" and "FiLeNaMe" should be considered the same? My program presents writes a level 3 ISO9660 file system. Windows is unable to deal with this correctly. (I seem to be the only one actually writing level 3 ISO9660) Thus I need to read it myself. This works just fine in normal ISO9660, but as soon as I add joliet extentions I have to change to unicode, and there I am case preserving. (as joliet requires) However windows is not case sensative, and there I'm not sure what to do. The easy solution is to convert to ASCII, which is easy to convert to upper case, but that won't work for anything other than latin derived languages (I wouldn't be surprized if some of them had special case that didn't work), with unicode I'm already close to supporting other languages correctly, I'd like to go the rest of the way if I can. Thus the question, can I access whatever function windows uses to convert case, in unicode?

    J 1 Reply Last reply
    0
    • H Henry miller

      Is there an easy way to compare two unicode strings that isn't case sensative. That is "fIlEnAmE" and "FiLeNaMe" should be considered the same? My program presents writes a level 3 ISO9660 file system. Windows is unable to deal with this correctly. (I seem to be the only one actually writing level 3 ISO9660) Thus I need to read it myself. This works just fine in normal ISO9660, but as soon as I add joliet extentions I have to change to unicode, and there I am case preserving. (as joliet requires) However windows is not case sensative, and there I'm not sure what to do. The easy solution is to convert to ASCII, which is easy to convert to upper case, but that won't work for anything other than latin derived languages (I wouldn't be surprized if some of them had special case that didn't work), with unicode I'm already close to supporting other languages correctly, I'd like to go the rest of the way if I can. Thus the question, can I access whatever function windows uses to convert case, in unicode?

      J Offline
      J Offline
      Jim Crafton
      wrote on last edited by
      #2

      I ran into something liek this for some code I had to write for my project, the VCF.

      int Win32LocalePeer::collateCaseInsensitive( const UnicodeString& s1, const UnicodeString& s2 )
      {
      int result = 0;
      if ( System::isUnicodeEnabled() ) {
      result = ::CompareStringW( lcid_, NORM_IGNORECASE, s1.c_str(), s1.size(), s2.c_str(), s2.size() );
      }
      else {
      AnsiString tmp1 = s1;
      AnsiString tmp2 = s2;

      	result = ::CompareStringA( lcid\_, NORM\_IGNORECASE, tmp1.c\_str(), tmp1.size(), tmp2.c\_str(), tmp2.size() );
      }
      
      return result;
      

      }

      DOn't know if this is exactly what you want but here's hoping! :) ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned

      J H 2 Replies Last reply
      0
      • J Jim Crafton

        I ran into something liek this for some code I had to write for my project, the VCF.

        int Win32LocalePeer::collateCaseInsensitive( const UnicodeString& s1, const UnicodeString& s2 )
        {
        int result = 0;
        if ( System::isUnicodeEnabled() ) {
        result = ::CompareStringW( lcid_, NORM_IGNORECASE, s1.c_str(), s1.size(), s2.c_str(), s2.size() );
        }
        else {
        AnsiString tmp1 = s1;
        AnsiString tmp2 = s2;

        	result = ::CompareStringA( lcid\_, NORM\_IGNORECASE, tmp1.c\_str(), tmp1.size(), tmp2.c\_str(), tmp2.size() );
        }
        
        return result;
        

        }

        DOn't know if this is exactly what you want but here's hoping! :) ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned

        J Offline
        J Offline
        Jim Crafton
        wrote on last edited by
        #3

        lcid_ is a member value that is a valid LCID for the locale you want. UnicodeString is just a wrapper around std::basic_string<wchar_t>. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned

        1 Reply Last reply
        0
        • J Jim Crafton

          I ran into something liek this for some code I had to write for my project, the VCF.

          int Win32LocalePeer::collateCaseInsensitive( const UnicodeString& s1, const UnicodeString& s2 )
          {
          int result = 0;
          if ( System::isUnicodeEnabled() ) {
          result = ::CompareStringW( lcid_, NORM_IGNORECASE, s1.c_str(), s1.size(), s2.c_str(), s2.size() );
          }
          else {
          AnsiString tmp1 = s1;
          AnsiString tmp2 = s2;

          	result = ::CompareStringA( lcid\_, NORM\_IGNORECASE, tmp1.c\_str(), tmp1.size(), tmp2.c\_str(), tmp2.size() );
          }
          
          return result;
          

          }

          DOn't know if this is exactly what you want but here's hoping! :) ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned

          H Offline
          H Offline
          Henry miller
          wrote on last edited by
          #4

          Thank you. I knew there had to be an easy way, but I didn't find it when I searched. (I didn't search the right places to find it) I don't know that it works, but if it doesn't the bugs are mine now...

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups