RTC Forums
November 24, 2024, 05:34:17 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RtcString Confuse  (Read 6825 times)
Theprasit
RTC License++
*****
Posts: 42


« on: May 30, 2013, 12:59:52 PM »

Face some problem with RtcString() with Huh? character.

Retrieve data from both AS400 and SQL Server via AnyDAC, string field return and display correcly in Thai characters.

Passing that data via RTC using DelphiDataSetToRTC and DelphiRowToRTC from rtcDB unit, all Thai characters display with Huh? characters.

After some investigate, I recognize some code in both procedure with comment in about:-
 rtc_text: rtcDS.asText[fldname]:= field.AsWideString;

After comment this line out, data is display properly.

Seem that it's about converting string fields between DataSet and RTC. I go through document and some code in rtcInfo to find out about rtc_string type but a bit confuse.

In rtcDefs.inc had this 2 line defined as default

{.$DEFINE FORCE_ANSI_STRING} // set type RtcString = AnsiString ?
{.$DEFINE FORCE_WIDE_STRING} // set type RtcString = WideString ?

This mean that RtcString = String, am I correct. If so while the code

 rtc_string: rtcDS.asString[fldname]:= RtcString(field.AsString);

is fail to convert., or database I connected return with AnsiString. If so, do I need to add more line of code to verify the return type from dataset as AnSiString.

Could you give me more explanation about rtc_string on this case.

I tested on RTC 605 on windows 7

Thank you and Regards,

P.S. I did more test after this on my own server with SQL Express default setup, everything when fine with out any modification in rtcDB.
Logged
Kevin Powick
RTC Expired
*
Posts: 87


« Reply #1 on: May 30, 2013, 02:29:24 PM »

Have you checked this TOPIC (it contains more information)?

Logged

Linux is only free if your time is worthless
Theprasit
RTC License++
*****
Posts: 42


« Reply #2 on: May 31, 2013, 04:33:24 AM »

Thank you for your info., and after went thru that info. I'm still confuse!, sorry.

The problem I faced is a new project using Delphi XE and I'm assume that the code in rtcDB is unicode ready but the result is as I said.

So, this mean the code in "DelphiDataSetToRTC" and others is not properly for old AnsiString, if so I will modify to resolve my issue.

Thank you and Regards,
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: May 31, 2013, 12:43:09 PM »

DelphiDataSetToRTC and RTCDataSetToDelphi functions are only examples, which have been tested with the BDE. If you are using any other database engine, you need to copy the code from these functions and make your own version for that specific database engine, beause different database engines will most likely be handling data differently.

On the RTC side, you need to use the "asText" property for Unicode Strings. The "asString" property is ONLY for 8-bit character Strings and should NOT be used for Unicode. The same goes for all methods and properties declared with the RtcString type. They work ONLY with 8-bit character Strings. For sending Unicode data, you have to perform conversions, depending on the format expected by the receiver. For example, if your receiver expects UTF-8 Strings, you can use Utf8Encode and Utf8Decode functions.

Best Regards,
Danijel Tkalcec
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #4 on: June 02, 2013, 11:32:48 AM »

Thank you for your answer, this is much more clear for me.

Best Regards,
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #5 on: July 27, 2013, 05:47:23 AM »

Sorry again on this topic.

I faced a problem with Thai characters when using TRtcDataSetMonitor. The reading is fine but the updating return with "HuhHuh" instead of Thai characters.
I went thru the code of TRtcDataSetRecorder and found that it's use "DelphiRowToRtc" from rtcDB and the code had a line comment on this.

          case RTC_FIELD2VALUE_TYPES[rtcDS.FieldType[fldname]] of
            rtc_Currency: rtcDS.asCurrency[fldname]:=field.AsCurrency;
            rtc_DateTime: rtcDS.asDateTime[fldname]:=field.AsDateTime;
            rtc_String: rtcDS.asString[fldname]:=RtcString(field.AsString);
            // rtc_Text: rtcDS.asText[fldname]:=field.AsWideString;
            else rtcDS.Value[fldname]:=field.Value;
            end;

If I uncomment "rtc_Text:.. ." my program work just find (I already noticed on this as per previous discussion).

My question is, as per TRtcDataSetMonitor is standard component and will have some more enhancement from time to time, so modify its code is not recommend, right?
What is the better to handle this issue? or I have to modify the code on every version update?

Regards,

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: July 29, 2013, 12:47:47 PM »

I've updated DataSet Field conversion routines in the "rtcDB.pas" unit to force the use of Unicode Strings for all Text types when compiled with Delphi 2009 and later. This change is now available for download from the RTC SDK Downloads area (RTC SDK v6.20). Let me know if you encounter any other problems.

Best Regards,
Danijel Tkalcec
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #7 on: July 30, 2013, 08:30:30 AM »

Danijel,

Thank you for your fast response, your new update code is more better than I expected. Cheesy

Currently, I'm working on XE, so forgot about this compiler directive. Will inform you more if I faced another issue.

Thank You and Best Regards,

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.028 seconds with 17 queries.