instr doesn't work for unicode (utf-8)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: instr doesn't work for unicode (utf-8)

  1. #1
    Join Date
    Mar 2008
    Posts
    1

    instr doesn't work for unicode (utf-8)

    I am using instr to search for strings from pages I have read into a variable. When the page uses "charset=UTF-8" then the comparison fails. Here is my code
    iPlace = inStr(1, sContent, sSearchTerm, vbTextCompare)
    Does anyone know how to do search for strings in unicode?

    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    First you need to know ahead of time if sContent is a unicode string or not.
    The conversion function will trash the value if it is not a unicode string.
    So if you can detect weather or not it is a unicode page, then set a
    flag variable, and use it to know when to use the conversion function.
    Code:
      If IsUnicodeFlag Then
        sContent = StrConv(sContent, vbFromUnicode)
      EndIf
      iPlace = inStr(1, sContent, sSearchTerm, vbTextCompare)

Similar Threads

  1. Data Entry Work
    By Anjana Jonathan in forum Careers
    Replies: 5
    Last Post: 07-03-2006, 03:15 AM
  2. Replies: 0
    Last Post: 10-15-2001, 07:52 PM
  3. Justification for tele-commuting
    By Jason Langston in forum Careers
    Replies: 10
    Last Post: 08-08-2000, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center