Re: Accessing character set information
Posted by: Alexis Maiquez
Date: September 07, 2022 07:44PM

Sorry, I should have been a bit more clear from the begining. This is gonna be a bit of a long post...

I'm writting a server emulator for the EVE Online game, which is based on Python 2.5. Due to how the game is developed, there's two types of strings the game can send/receive: ASCII and UTF-8. The type of string you send back to the client matters as sometimes those strings can be used as array keys or other things (ASCII strings are byte strings, and UTF-8 are unicode strings, which are handled differently) where the type of string matters.

When the app boots up I'm querying INFORMATION_SCHEMA and extracting the encoding of all the database fields and keeping that in a dictionary, so when I'm taking a database result and encoding it in the game's data types I can look up the database field in the dictionary, get the encoding, and produce the proper string type.

This approach works almost fine, except when there's an UNION query, in those situations I cannot determine the encoding of the data that I'm getting back.
It also means that I need to pass a custom class everywhere so I can keep the dictionary with the encoding mapping available, which is not ideal as that also forces me to have the database logic where the game objects are built (instead of having the building of game objects separated from the actual database code). Ideally I would be able to just write extensions for DbDataReader or MySqlDataReader and use that everywhere. After looking at the data the MySqlDataReader has access to, looks like it's stored when reading the column value, so I wonder if there's any way to access it without reflection, or if it could be implemented in future versions a method like GetCharacterSet (int field) to have access to it. (unless there's an alternative way of accessing it).

Options: ReplyQuote

Written By
September 06, 2022 11:06PM
Re: Accessing character set information
September 07, 2022 07:44PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.