Closed palevi67 closed 1 month ago
@palevi67 you should check rows.Err() after loop.
https://pkg.go.dev/database/sql#Rows.Next
Next prepares the next result row for reading with the Rows.Scan method. It returns true on success, or false if there is no next result row or an error happened while preparing it. Rows.Err should be consulted to distinguish between the two cases.
Yes @bat22, you're right! I have consequently updated the above test, and this time I get the following error:
opFetchResponse:Internal Error
Do not encode to a specific character encoding.
In the above example
dream := "sueño"
instead of
dream, err := charmap.Windows1252.NewEncoder().String("sueño")
Yes, this way is working, thought in this case "sueño" gets encoded as UTF8 ...
I guess that if you don't specify any encoding in the URL then UFT8 is assumed. And that is why you get an "Internal error" when data don't represent a valid UTF8 sequence.
I'm I right?
I think the driver can handle utf-8 encoded strings, which is good enough.
when you want to pass Windows 1252 encoded strings?
Not knowing which encoding the parameter string is, when converting it to a byte slice for query parameter
so
You may get the result you want if you pass a byte string as a parameter.
Yes, this way is working, thought in this case "sueño" gets encoded as UTF8 ...
I seems to me that if you don't specify any encoding in the URL then UFT8 is assumed. And that is why you get an "Internal error" when data don't represent a valid UTF8 sequence.
I'm I right?
when you want to pass Windows 1252 encoded strings?
I'm working in an windows environment with a WIN1552 which passes the data to other WIN1252 app, so no encoding seems the natural choice. Adding encoding=None to the solves my problem, I just didn't notice that the default encoding is UTF8 ...
Sorry for the trouble ...
When retrieving a string from a database with charset=None the driver does not know if it is WIN1552 encoded or not.
I have a case where a "for rows.Next() {}" loop does not get all the rows. Curiously it only fails when no charset is specified, but with charset=None or charset=whatever it works correctly.
I include a test case:
Tested in FB 2.5.9 + W7 and FB 5.0.0 + W11. Database charset is NONE and test table is:
Is there any difference between charset=None and no charset?