New topic: Text Encoding?
<http://forums.realsoftware.com/viewtopic.php?t=46157> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message BrianOBrien Post subject: Text Encoding?Posted: Thu Dec 06, 2012 1:53 pm Joined: Wed Jul 07, 2010 2:55 pm Posts: 630 Location: University Of Calgary, Faculty Of Medicine (Pardon the double post) I have a database query that returns a record set of strings. I am looking for rows where a column has a lower case character in it. do until rs.eof PatientID = rs.IdxField(1).StringValue UPatientID = PatientID.Uppercase if PatientID.left(1) = "f" then MsgBox("Halt") end if if PatientID <> UPatientID then listbox1.AddRow PatientID end if rs.MoveNext Loop The code halts at the MsgBox, but the Patient ID is FXXXX I suspect this has something to do with text encoding but I'm not sure what. For the moment lets assume that the text is ASCII. Where did I go wrong: 1) In the column encoding at the database? 2) When I defined the PatientID string variable? _________________ If at first you don't succeed... Try REALBasic. Top ktekinay Post subject: Re: Text Encoding?Posted: Thu Dec 06, 2012 1:55 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 290 Location: New York, NY See my reply in the other post. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top BrianOBrien Post subject: Re: Text Encoding?Posted: Thu Dec 06, 2012 2:21 pm Joined: Wed Jul 07, 2010 2:55 pm Posts: 630 Location: University Of Calgary, Faculty Of Medicine Thank you so much for pointing out the StrComp method... Mind blowing... i've been programming in basic for ever and never ran across this. The Encoding on these string is supposed to have been ISO_IR 100 So If I can carry this question further... 1) If I want to set the encoding of a string to ISO_IR 100 how do I go about it? 2) How can I print out the current encoding of a string? 3) Are the strings from SQL rs.idxfield(1).StringValue encoded according to the database schema or are they just unknown? _________________ If at first you don't succeed... Try REALBasic. Top timhare Post subject: Re: Text Encoding?Posted: Thu Dec 06, 2012 4:10 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11865 Location: Portland, OR USA BrianOBrien wrote:1) If I want to set the encoding of a string to ISO_IR 100 how do I go about it? Use DefineEncoding. Not sure which encoding corresponds to ISO_IR 100. Quote:2) How can I print out the current encoding of a string? PatientID.Encoding.InternetName Quote:3) Are the strings from SQL rs.idxfield(1).StringValue encoded according to the database schema or are they just unknown? They are undefined. You must define them with DefineEncoding. Top ktekinay Post subject: Re: Text Encoding?Posted: Thu Dec 06, 2012 4:12 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 290 Location: New York, NY The answers: 1) That Encoding is the same as ISO8859-1, according to Wikipedia, so you can use something like this code: static enc as TextEncoding // Will be cached if enc is nil then #if TargetMacOS enc = GetInternetTextEncoding( "iso8859-1" ) // Mac only #else enc = GetTextEncoding( 1280, 1280, 0 ) #endif end if fld = rs.IdxField( index ).StringValue.DefineEncoding( enc ) 2) To get the existing encodings of a string: dim enc as TextEncoding = s.Encoding MsgBox enc.InternetName // Or check other properties 3) I think the strings are returned as UTF-8, but don't know for sure. That's easy enough to check with the code above. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
