Results 1 to 11 of 11

Thread: ADODB Show Special Characters

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    4

    ADODB Show Special Characters

    Hi,

    Were you able to find a solution for this? I am working with a legacy, VB6 application that I have inherited. The application needs to display latin characters (é for example). Initial searches led me to believe the controls could not handle them, but labels and textboxes display hardcoded latin text without issues.

    When I look at the contents of the ADODB.Recordset, the watch window shows an 'e' and its respective hex (65) instead of an 'é' (E9). Is there some sort of a Recordset property that needs to be changed? I'm reading from an Oracle database which shows the characters fine when viewed via their SQL Developer (similar to Microsoft's SSMS).

    I would appreciate any suggestions. Thanks a lot in advance.

    -Kirandeep

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: ADODB Show Special Characters

    Moderator Actions: Thread spun off of https://www.vbforums.com/showthread.php?862299 onto its own thread from VB.NET to VB6 and Earlier
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: ADODB Show Special Characters

    Doesn't sound like an ADO issue to me. More likely you are using some Provider (or ODBC Driver via the shim Provider MSDASQL) or a query... that is "washing" characters to the straight 7-bit ASCII subset from whatever encoding they have in your database.

    Not sure anyone here can be very helpful without a ton of additional info. Even if we have Oracle we might fuss for days trying to reproduce this problem.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: ADODB Show Special Characters

    Yeah, I have to agree with Dil. If I had to guess, I'd say it's a setting in your database to save everything as ANSI, or possibly even ASCII. With codepages (which may not apply to an actual database), you can use 8-bit ANSI to get those tilde and acute accents, but that all depends on how it's saved in the database. It's highly possible that it's saved (and returned) as straight 7-bit ASCII. If that's the case, short of modifying your database structure, there's not much you can do.

    VB6's strings (internally) are 2-byte Unicode (the 2-byte characters of UTF-16, aka UCS-2). And, if a database is setup for it, it can write those strings into a database. There is the "got-cha" that most VB6's controls just take ANSI for text properties, but there are ways around that as well. But, before we delve into that, we've got to make sure you're actually getting Unicode out of your database.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: ADODB Show Special Characters

    Quote Originally Posted by Kirandeep View Post
    I'm reading from an Oracle database which shows the characters fine when viewed via their SQL Developer.
    I re-read your post, and that finally sunk in. Yeah, tell us how this VB6 program is "getting to" the database, possibly showing some code snippets on how the database is being opened, and how the recordset is being opened and read. That will help tremendously.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    4

    Re: ADODB Show Special Characters

    Thank you for pointing me in the right direction, guys. Upon your suggestions I looked into the driver--Oracle's OraClient11g. Specifying NLS_LANG to AMERICAN_AMERICA.WE8MSWIN1252 for the Oracle client home in the registry resolved my issue. I followed this (although I think they mean latin characters to basic ascii): https://stackoverflow.com/questions/...nt-in-select-r

    I am still a bit puzzled by a couple of things though. It's interesting that I could save the latin characters from the app into the database, but not retrieve them without specifying NLS_LANG. Secondly, not having the NLS_LANG key should default to American USASCII7 I think, which should include those latin characters, but it doesn't seem to work like that. Lastly my thought is that the ideal solution ought to change some attribute or property of the adoconnection to specify the language/characterset, so that my changes don't impact any other application using the Oracle client. However after a few days of searching, I'm ready to take my small win and call it a day.

    Edit: Correcting my comment regarding US-ASCII7 for future readers, as dilettante points out. The 7-bit, 128 characterset includes just the basic English characters. So if the NLS_LANG parameter isn't set in the registry, the OraClient 11gR2 on Windows 7 and Windows 10 seems to default to AMERICAN_AMERICA.US7ASCII.
    Last edited by Kirandeep; Dec 28th, 2021 at 10:36 PM.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: ADODB Show Special Characters

    ASCII only has 128 characters. It gets confusing when people have tried to repurpose the other 128 possible byte values for various things.

  8. #8

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    4

    Re: ADODB Show Special Characters

    I felt like something seemed off right after posting...hehe...and confirmed the ASCII7 set. Sure enough the 128 characters don't include the latin characters. Those are part the extended set. I couldn't figure out how to edit my post since it had been submitted for review.

    Anyways, thank you and Elroy so much for the prompt responses and all your help. Appreciate it!

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: ADODB Show Special Characters

    Letters A through Z are the "Latin" characters, I think you are referring to their accented forms, which ASCII does not contain.

    I suspect you are thinking of ANSI encoding, where for "non-Latin" code pages the values 128 through 255 contain different sets of symbols.

  10. #10
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: ADODB Show Special Characters

    Yeah, the 7 in USASCII7 was the clue to me. That's not going to include any alphabet characters except for the plain vanilla USA alphabet. I recently posted those (on an ASCII table). Let me find that link:

    Name:  AsciiChar.jpg
Views: 527
Size:  53.6 KB

    And other than some control characters in the <&h20 range, that's it.

    P.S. A &h7F maxes out 7 bits.
    Last edited by Elroy; Dec 29th, 2021 at 11:34 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  11. #11

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    4

    Re: ADODB Show Special Characters

    Quote Originally Posted by dilettante View Post
    Letters A through Z are the "Latin" characters, I think you are referring to their accented forms, which ASCII does not contain.

    I suspect you are thinking of ANSI encoding, where for "non-Latin" code pages the values 128 through 255 contain different sets of symbols.
    I think I end up thinking "Latin" characters and "Latin-1" character set as the same, but you're right. Google search results for "latin characters" can be summed up as our English alphabet. I learn something every day

    Searching for "latin character set," however, brings up what I had in mind--the character set that has the ability to display most (I think) of the Latin derived languages including Spanish, Italian and French where accented letters are used. But hey, if I don't think about it seriously, I even limit Latin to just Hispanic and then just Spanish language-representing characters in my mind...hehehe.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width