I’m looking to move my Web App to 2021R1. I’m using the same code that I used in 2020R2, but when I’m trying to grab strings from rows in a MySQL database I’m getting an InvalidArgumentException. The message it gives me is: root{"xojo_value"}: String value does not have a specified encoding.
I was able to fix it by adding .DefineEncoding(Encodings.UTF8) to wherever I’m I’m using stringvalue. For all of this I am just putting the Strings into a Listbox. In 2020R2 this all worked fine, but in 2021R1 I have to use the DefineEncoding. So my questions are this:
Is there a way to default define this encoding for StringValue(I’m sure this is far out), or a way to fix the issue I’m seeing? I just don’t want to have to put this DefineEncoding all throughout my code, as I do this a lot.
(Off Topic a bit) When I looked at InvalidArgumentException in the documentation it says that it was Deprecated in 2021R1… So why would I be seeing it?
I have seen this as well with JSONItem / RowSet. It’s incredibly frustrating and I’ve had a client say “Well, I don’t want to beta test this for them” - about the 2021r1.1 release.
If anyone knows how to resolve this without defining encoding literally everywhere, please let me know. We do use the SET NAMES UTF8 trick, but that does not seem to help 2021r1.1.
@Anthony_G_Cyphers it seems that trick no longer works in 2021, do you have any ideas why?
MYSQL 8+ uses as standard 'utf8mb4_0900_ai_ci', Unicode 9.0, and I think that tables encoded as utf8mb4 standard can fail trying to use the previous utf8. Not sure, but probably some conflicts may rise.
I’ve just finished testing the COLLATE utf8 suggestion to no success.
For what little it’s worth, this is what’s causing the exception:
const kSQL = "SELECT * FROM Users WHERE Username = ?"
var oRS as RowSet = DB.SelectSQL(kSQL, "UsernameLookup")
var jsResponse as new JSONItem
jsResponse.Value("User_ID") = oRS.Column("User_ID").StringValue
// Exception happens here, with ToString highlighted
var sResponse as String = tjsResponse.ToString
InvalidArgumentException: root{“User_ID”}: String value does not have a specified encoding.