Re[2]: [fpc-devel] TStringField, String and UnicodeString and UTF8String
Hello FPC, Thursday, January 13, 2011, 10:03:02 AM, you wrote: ODBC 3.5 was launched around 2000-2001. L But this approach will require changes in packages/odbc/src/odbcsql.inc L like, does not ?: L -pointer(SQLGetData) := L GetProcedureAddress(ODBCLibraryHandle,'SQLGetData'); L +pointer(SQLGetData) := L GetProcedureAddress(ODBCLibraryHandle,'SQLGetDataW'); L And I do not know how it affect compatibility for example in UNIX or if L all ODBC drivers support this functionality. Most probably it needs a flag to indicate that the ODBC must work in Unicode, and then dynamic link to *W functions if this flag is set. I think ODBC drivers since 2002+/- should have this set of APIs, but I had never used ODBC in my life... :) L But also in this case we will get UTF-16 widestrings (in Windows) not L UTF-8, does not ? That's not important, you get unicode in the specified by the API format, then SQLConnector fills information in the expected target format (WideString, UTF8String over AnsiString, Raw bytes...). -- Best regards, José ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re[2]: [fpc-devel] TStringField, String and UnicodeString and UTF8String
Hello FPC, Thursday, January 13, 2011, 1:01:57 PM, you wrote: L Also it seems to me, that when you call ANSI version of ODBC API L functions, then you receive data in ANSI encoding. L If it is so, then it is always safe use ansitoutf8() (or UTF8Encode()) L on receved data. No, because ANSI is not UTF-* so any char outside of your ANSI codepage will be discarded or generate and exception, or whatever the developer decides (driver developer). L In Windows we get UTF-16, in Linux/UNIX we get UTF-8 If you use ANSI calls in linux you will receive UTF8 because in most linux the ANSI page is UTF8. If you call the *W APIs you MUST receive WideString or PWideCharArray or alike, or the API will not work. -- Best regards, José ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: Re[2]: [fpc-devel] TStringField, String and UnicodeString and UTF8String
On Thu, 2011-01-13 at 10:32 +0100, José Mejuto wrote: Hello FPC, Thursday, January 13, 2011, 10:03:02 AM, you wrote: ODBC 3.5 was launched around 2000-2001. L But this approach will require changes in packages/odbc/src/odbcsql.inc L like, does not ?: L -pointer(SQLGetData) := L GetProcedureAddress(ODBCLibraryHandle,'SQLGetData'); L +pointer(SQLGetData) := L GetProcedureAddress(ODBCLibraryHandle,'SQLGetDataW'); L And I do not know how it affect compatibility for example in UNIX or if L all ODBC drivers support this functionality. Most probably it needs a flag to indicate that the ODBC must work in Unicode, and then dynamic link to *W functions if this flag is set. I think ODBC drivers since 2002+/- should have this set of APIs, but I had never used ODBC in my life... :) This has only effect on the passed parameters to the ODBC-functions. ie: the field-names, table names and such. Joost. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re[2]: [fpc-devel] TStringField, String and UnicodeString and UTF8String
Hello FPC, Thursday, January 13, 2011, 2:58:30 PM, you wrote: JvdS Then that option has to be added. I think it's already possible but you JvdS simply don't know how. (Sql-Server is ODBC only, so that one is fixed. JvdS For firebird there's a 'serverencoding' parameter, or something like JvdS that. Postgres also has some setting. Are you aware about the Firebird Field(UTF8) and SQLConnection CharSet(UTF8) problem ? Table X --- FieldTestName Varchar(5) UTF8 IBConnection --- CharSet = UTF8 //Source code file is UTF8 encoded. DataSource.FieldByName('FieldTestName').AsString='Ñ'; This raises an exception because the string is 10 bytes and the field only allow 5 chars. I think I had read this comment many months ago and answered as won'n fix for Interbase compatibility. Am I wrong ? -- Best regards, José ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: Re[2]: [fpc-devel] TStringField, String and UnicodeString and UTF8String
On Thu, 2011-01-13 at 15:55 +0100, José Mejuto wrote: Hello FPC, Thursday, January 13, 2011, 2:58:30 PM, you wrote: JvdS Then that option has to be added. I think it's already possible but you JvdS simply don't know how. (Sql-Server is ODBC only, so that one is fixed. JvdS For firebird there's a 'serverencoding' parameter, or something like JvdS that. Postgres also has some setting. Are you aware about the Firebird Field(UTF8) and SQLConnection CharSet(UTF8) problem ? Table X --- FieldTestName Varchar(5) UTF8 IBConnection --- CharSet = UTF8 //Source code file is UTF8 encoded. DataSource.FieldByName('FieldTestName').AsString='Ñ'; This raises an exception because the string is 10 bytes and the field only allow 5 chars. I think I had read this comment many months ago and answered as won'n fix for Interbase compatibility. Am I wrong ? See my mail to Lacak about the two options to solve this. Joost. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel