bikotronic
|
|
« on: February 19, 2021, 11:35:37 AM » |
|
Hi, i have a client server application with the rtc components TRtcServerModule TRtcFunction TRtcDataServerLink TRtcHttpClient i send a xml file with russian charset from server to client, on send the russian chars are ok, on recieve russian chars are ' ??' i use the RTC Value Types --> rtc_Record, is the rtc_DataSet better for this? thx
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #1 on: February 19, 2021, 12:43:04 PM » |
|
If you are sending an XML file, make sure it is properly Encoded on the sender side (for example, using UTF-8) and decoded on the Client side.
If you are using remote functions and are sending Unicode Text, then you have to use "asText" on the Sender side to assign the Unicode String and use "asText" on the Receiver side to read it as a Unicode String.
Otherwise, only the lower 8 bits of every character will be sent and/or received.
Best Regards, Danijel Tkalcec
|
|
|
Logged
|
|
|
|
bikotronic
|
|
« Reply #2 on: February 22, 2021, 08:40:41 AM » |
|
thx for the info i use delphi 10.4.1, RealThinClientSDK_v951, win 10 pro 64bit is there a log function or a monitor function so that i can see exactly what the component is sending / receiving here is my send function and here the msg string #$FEFF'<?xml version="1.0" encoding="utf-8"?>'#$D#$A'<Content>'#$D#$A' <ROW>'#$D#$A'<ARTICLENO>01E0816</ARTICLENO>'#$D#$A' <SHORTNAME>ÄÜÖäüöß@€</SHORTNAME>'#$D#$A' <NAME>Толерантность</NAME>'#$D#$A' </ROW>'#$D#$A'</Content>'#$D#$A' //****************************************************************************** procedure SendMsg(aMsg, aNumber, key, aLoadData: String); //****************************************************************************** var S : String; begin // fclientmodul --> TRtcClientModule; with fClientModule, Data.NewFunction('SendMsg') do begin asText['msg'] :=aMsg; asText['date'] :=TimeToStr(now); asText['key'] :=Key; asText['number'] :=aNumber; asText['loaddata']:=aLoadData; Call(fSendMsgResult); end; end;
and here the receive string '?<?xml version="1.0" encoding="utf-8"?>'#$D#$D#$A' <Content>'#$D#$A' <ROW>'#$D#$A' <ARTICLENO>01E0816</ARTICLENO>'#$D#$A' <SHORTNAME>ÄÜÖäüöß@'#$0080'</SHORTNAME>'#$D#$A' <NAME>?????????????</NAME>'#$D#$A'</ROW>'#$D#$A' </Content>'#$D#$A' receive function //****************************************************************************** procedure OnGetMsgResultReturn(Sender: TRtcConnection;Data: TRtcValue; Result: TRtcValue); //****************************************************************************** var s : string; begin s:=Result.asText; //test --> wrong charset !!!
if Result.isType=rtc_Exception then begin
end;
if Result.asString=resError then begin Logout; exit; end;
if Assigned(FOnGetMsg) then FOnGetMsg(Result); end;
procedure fOnGetMsg(Sender: TObject); var aMsg: string; begin if TRtcValue(Sender).isType = rtc_Record then begin aRecord := TRtcValue(Sender).asRecord; if assigned(aRecord) then begin aMsg := aRecord.asText[aKEY]; end; end; end;
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #3 on: February 22, 2021, 02:29:53 PM » |
|
If you need to see raw data traffic of any RTC component, I'd recommend searching for calls to "Write", "WriteEx", "Read" and "ReadEx" methods inside the unit implementing the component you are debugging ("TRtcClientModule" is in the "rtcCliModule.pas" unit, "TRtcServerModule" is in the "rtcSrvModule.pas" unit). Setting breakpoints inside RTC code and running your code in a debugger is most likely going to show you the exact place where your data gets corrupted, especially since you should also have access to the original data there. If you are sending your XML file to the Server and then back to the Client, you should check both sides.
Best Regards, Danijel Tkalcec
|
|
|
Logged
|
|
|
|
bikotronic
|
|
« Reply #4 on: February 24, 2021, 09:37:31 AM » |
|
thx, but this is not working for me. its look like encrypted. EncryptionKey is 0 on the components s:=RtcBytesToString(Data); for debug info, write byte array to string //Send s 'xÚí'#$009A'Ýn£F'#$14'Çï+õ'#$1D'F¹j¥5Ì'#$C'3|tIܱ'#$0083#$1D'Ë_'#$11'8i×wl̺¨Ä'#$008E'0^õ²'#$F'×gèU¤Þô'#$19'z'#$0095#$008B#2'Æ'#$0089'wk'#$E'^«'#$008D#6'«¹ÉÌ'#$009C'?vàÇ'#$0099'sø'#7'×9''o-ÊÚ'#$009C't¨Ð¬6ÃÌ'#$10#6'£'#$0097'ZGh'#$009D#$16'wt'#$008E'¿óÎ'#9'3uó¬i7'#$7F'¹'#$008F'ÐÇ ^'#$0085'ËÅù'#$19'Qð'#$19#$A#$16'wËY¸'#$0098#$009F#$009F#$00AD#$0093#$F#$008D'TtñõW¶'#$0098'Ïã`î'''#$0081#$17'FËör'#$0091#4#$008B'$]GÈvÇ?ä'#$0083't8'#$14#$0093'É»ë'#$B'b«Å¨X÷z'#$0083'ñh'#$009C#$00AD#$17'£b]¸'#$0093'^{à¤'#$B#$0098'8Ø$º'#$00AD'¾,m'#$008F'½'#$1A'»'#$0093#$0091#$18':'#$17#$008F'Of#'#$0093'¼¬'#$14#$0092'|üÛãï'#$7F'>ýõÇ÷¿Úênl"Ü®3¹'#$15#$0083#$1B'ç'#2'ÛêîtûG´''7bð¬Ø'#$009D#$16#$008A'Ë^§'#$0093'/ô»'#$0099'bwú¹âÚ'#$1D#$7F'"ÉæÏ'#$17'g´û=»ÓB±'#$0099'X'#$0096'¢'#$1B'ÔVÿ'#$19'º'#$19'õ&'#$17'I'#$11'É''Ûèxp'#$0093#$009E'2Áéç'#$16'ãO"Ï'#7'¾Ìrtê'#$0096'Ý'#$17'@¤ D¢S'#$A'B$z#SìgØÜý9'#1#$008E#$1A'cÒrÔ '#$008E#$1E'Æ'#$18'æ'#$0088'U'#$0090'â'#9'ÀÃÙ^#)<ö'#$009F'ÁóüÅ'#$C'åñ'#$009A#3'4'#$15'Ý4¥'#5'È«'#0#$0092#$A#$0080'¤'#2' 9'#1#$0080#$009A'¼'#9'¨ÿϯ'#$009A#$1F'Öämc'#$C#8'`'#$1F'3l'#$0082#0'YÃ,'#3'Ø'#$F#$0083#$15'Êã5'#7'h('#6#$0096'·'#$7F'1«2'#$0090'Ud '#$0083'3°ÁN'#0' fÈ»'#$0085'Z'#$10'À'#$16'¦'#$0098#$0083#0'[>Uy'#$19'Â'#$0096'¿ò£'#4'Ñ'#6'?'#1#$0088#$0098'ÉÛÇ'#$10#$C'¦a'#$0097'j D'#$F'z¢÷'#$1E'¢0IÐFRs'#$008A'º"ñ#='#1#$008D#$0099'K'#$F#$0093#$008A'\ìC'#$18'ózx"'#$10'5Kb'#$008A' 3#~L)ÂÉØ'#$A'©ZÚÕ´Âû'#$15'Êãµ'#$0087#$0088'õWíjÒ'#$0093'Þë'#$009D'6ívp'#$009F#$008E#$E'0Té'#$11#$0086'*m'#$13'Fù'#8'$ÞC'#$008C'*'#$1C']yeÔÛÎ'#$10#$15'¢QÝÉ3Káºv'#$C'yþ/f/=ÂV¥m*'#$0086'Õ0_@'#1'0{ªh'#$C'¿ñ'#$1A#$0083'oSõ'#$009B'ÓÀJ¨.+VÈe¥'#$1D#1#2'í<'#$E#6#$008E'[F³'#$13#$00AD'çþêî§ ö'#0'3§Î'#$0092#$15' '#$0083'·XN¹[±Åò,)]x'#$0087'ÝjjO'#$0092'r*+I'#$E#$0092'Ô'#$0084'FyÅþÚC'#2'ié¦'#9'o°'#$1B#$0095'Rû''Of(&á²ÒÔ+h'#$1E'P.SPì '#$009A'''R(3;È'#$0094#$0095'§'#1'ól¥Ù9'#$12#$0095'@['#7'åçF'#$0085'F'#$0083'«´õE#¿öduÅbDV²fe¦¾94UG'#$0087'æj#»Wj'#$F#$0095#$1F'g¿¿'#6'T'#$B'n'#$008B'´ê¶(KÁ'#$008A'®(ÏR÷'#4'@bÝ'#$0090#$15'$hàn<'#4'·ÒC¨$ÉN'#$0083'$W^Õ@°Õ='#$E'QÓ'#$16'³Y'#$0098#$0084#$1F#$F'y'#$13#$008F#$1D'a'#$1C'i'#$1E''''#$16'ìÚ÷ß¡\³'#$1F'ùÐ_%AÜ'#$008D#$0082'E¸¾GÏâ'#$009A'û'#$0086'¼'#$009C'üÏsÐ5'#$0084'àç'#$0087'~A'#$1A'³#ì#'#$00AD'+'#$0098#$0086'a«a'#$0088'DÛA¹l?Ônz`ïfGVs'#$009C'X'#$0097#$19'''d'#$1B'i×·S'#$008A'áMùv'#$008A'rÉ~'#$0096'×ãét<èM®6¢z'#$0093'4¹%3IÈ?Ò'#$0086'"½'#$F'áÌ'#$14'='#$17'Y¸¡'#$0097'&æ0¼'#$008B#$0097'H'#$0084'ñVVs'#$009C#$0084'Ê'#$008C#$0093#$0083'8;}'#6'¿uÒºE'#$009D'>b¥¯'#$009E#$C'×±ÿ'#$10'¥õs+«7LCç2ÃÔA'#$0098'YÕ$'#$0087'UMrX+ô,®9Ub¾2Õô¤÷õ¼MÛ{'#8'îB?'#$1A'úéUN'#$7F'ïD'#$0091#$009A'ÿ'#$0087'u'#$19'-cr@£l'#$1E'Ñ(W<'#$18'¹Ë¤ì¶HCóe4«}'#$13'EM'#$19'ÒÛ<¢''æS'#$0090']7'#$0088'Þ'#$0097'Á'#$009B#$0086'I¼\'#4'õï'#$009B't'#$0099'áA'#$1D'0'#$0087#$008D'ànü´('#$0083''''#$1E'>'#4'Qí7`'#$0093'É'#$008C#$E'jy¹Ó'#$0082#$1B'¤Ø_'#$0097'ÂsâÙûM¼î'#5#$0094'¾z'#1'ÝS'#9#$008B'òH?«'#$009A'goÿ'#6'ãÑ)Ì'
//Receive s 'xÚí'#$009B'MoâF'#$18'Çï'#$0095'ú'#$1D'F'#$009C'ZiÁ3ã'#$19'¿'#4#$0092#$00AD'a'#$D'A`'#$0088'l'#$0092'v¹9ÁK'#$00AD'u 2fÕÞÚ¨'#$0087#$1E'zn«j¥JÕ'#$1E'Z©'#$0087'½´'#$0097'Ín'#$F'|'#1'ò'#$15'zNկбy'#9'»Åc'#$16'µ'#$0091#$008D'ö'#$0094#$0099'yþ'#6'ÌÏÏ<'#$008F'ÿ8Õʾå'#$C'zƨ_4õ}Z<'#$1F'õ÷:û'#$0088'¨'#$0088'äþ~ñGéþgç'#$1E'xâø#w8ØÏ¡'#2'Ì'#1'gp6ì¹'#$0083'þ~n'#$1C'<Ê+¹û'#7'ï¿WÒú}ßéÛ'#$0081'c¹Þ°2'#$1C#4'Î `ë'#0#$0094'ÌöÇÑ'#$0080#$D#$D#$00AD'Óyxt'#$0080'JÂ|4_·êÍv«'#$1D'®ÏGóuÍìÔ+M'#$009D'-@¤C'#5'I%áviqìaÛì´4C?'#$0098'<'#$009D'\)ùPt»6'#$17'Íâ_1Å·'#$0093'g'#$0093'«Éï'#$0093#$1F'?úóò×'#$0092'°*êhfMï'#$009C'hÍcý'#0#$0096#$0084'ÕéâóT:ÇZs©X'#$009D'Î'#$15#$F'êÕj´Ð¨'#$0085#$008A'Õé'#$009B#$008A'#³ý'#$009A'$'#$009C'/¿§Öêû¬Nç'#$008A'ÙDU'#$B#$0092#$008C'K¿CÇ'#$00AD'zç '#$0098'G¢É"Ún'#$1E'³SF'#$0090'½î|üZdyàí,¢(,0¾'#5'OÌå'#$0089'$'#$008C'¹<'#$0091#$0094#$F#$15'ëaN'#$7F#$009A'¾'#$009A'¾'#$0098'þvýÅôùôåõåôåôÕõ'#$0097'×'#$0097'×ßì'#0'T'#$0091#$0090'ÔB'#$15'yP-'#8'!'#$1F'*'#$14'b'#$0091'þõÝ×7?üróý³'#$009B'ç?ï'#0'D'#$18'îD)'#$0085'Hþ7'#$0088#$0096'=è'#$0081'('#$009E'q'#$0080'JAR'#$0094'Ô'#2'¤I'#0'Q'#2'@'#$0094#0#$10'í'#0'@1½'#9'(½ã'#$0097'Ì'#$F#$008A'éímd'#$1E'À'#6'$Pá'#2'$y%'#$E'`ÃuF '#$008A'g'#$1C' \'#$0090'azû'#$18'%)'#3'IB'#6#$12'~'#6'æÉ'#$E#0#$14'åôn¡*'#$F'`'#$19'bH¹'#0'Ë6'#$16'h'#$1C'²=²½'#0'à<Ý'#1#$0088#$0090'¤·'#$008F'A'#$0090#$009B#$0086'5,r!Z¼û}ëÂs'#$0083#0'Ì$'#$19'§('#$15'R|'#$009F#$008F'¸ÆÍ'#3#$B'¢'#$0084'\lð0FõpG '#$008A'j'#$008A')rí'#$1A'í'#$13'F'#$0091#$009F#$008C'e'#$17#$B'±]MÙ='#$1F#$0081'('#$009E'y'#$0088'PºÓ®'#$0086#$009D'ôZo5tg+Î9'#$1B'o`¹â-,W\A'#4'Ó'#$16#$0097'y'#$1D#$10'\ àÐ'#$008A'ã^Ñ'#$D'0'#$17'µ²Î'#$009E'¨'#5'*'#$0089'Û°§ÿaþâ-ÜV\Á'#$009A#$0091#$C'ó'#$16#$14#7'f]ÐòÆ'#7'V¾ù!SßÛ'#$D'¬'#8'KiÅÊó[qUã'#2#$00AD'N'#$009E'6'#$009B'º'#$19#$0087'³ê'#$008D'ûöèìS''ó'#4'C³NM+AÂßc)¦fÂ'#$1E'Kì4ù[ìB'#$0093'y'#$0092#$0098'â´'#$0092'¤\'#$0092'¢&b'#$009A'°ÁÖ'#$0081#6'D¶kòwØ'#$0099'ª'#$0090'ù'#$009B'O"'#$17#$14'DÓJSJ ¹A½d ÈF4w¤R'#$0086#$008E#$0090#$0092'V'#$009E'2'#$009F'g'#$0099'egKK'#4'ZÞ(?g*Ðj'#$1E'²Þ'#$17'´ìÌ'#$0093#$0095#$A'*Ai%«$fê½MSµµi®æÃk%óPév'#$E'ü]@Uùm'#$0091#$0098'Ü'#$16#$0085')'#$0098'Ð'#$15'EYjî'#0'H(Éi'#5'Éõpg&'#$0082#$0099'h"$'#$0092'$»A'#$0092#$16'îÔA('#9'k,¢Ð9Òz=7p'#$009F'lò¸'#$1E'ÙÂ;'#$12'-'#$008A'T¾ußx'#8'"Ízè'#$0086'='#$A#$1C'¿æ9'#3'w|'#$E#$0096'â'#$008C#$009B#$0087'4'#$009E'ýã>×:äá'#$008F#$E'}'#$008B'D&[8HbM#"ä»'#$D#6'Ð*:'#$0088'dë¡ÖØ'#$0081'õã'#$15'YÆqB)Í8yÎ'#$0091'xtÒÅ'#$0090'¿-'#$009F'tA$YÏò¨Ýí¶'#$009B'õÎáL'#$0094'm'#$0092#$A'UÓL'#$0092'ç '#$0089#$0086'Æ®C~fju'#$13'¨0/Å&¦á'#$009E'ùC ¹þB'#$0096'q'#$009C#8'§'#$19'''åâ¬6'#8'ÿÑ'#$0093'ò'#9'¨6'#0#$0089'}þÄ'#$18'ûö'#$0085'ÇêçB'#$0096'm'#$0098'²DÓ'#$C'SâÂ'#$C'«&Ú¬j¢ÍZ¡¥8ãT'#$0091'rÇTÙI¯ëyÃfغpÎ\Û3lö=³¿+q Ì'#$7F'h'#$1D'zC'#$1F'mÐ,+[4Ë'#9'·Gæ0'#$0088'»4X¨?ôz'#$0099'o¤°'#$0092#$0086#$14'W¶è'#$008B'i'#$0097'Ë®æx§qðºnà'#$F#7'Nö{'')Íðx]0åÛÁ5'#$7F'r5'#$0088'£§]<r¼ÌïÂ'#$A'I3;^ßKõ2¿Kòíq,<Ýï'#$009D'ÎâY¯¢øΫè'#$009A'R¸¬'#$0090'ø'#$008D'Ò'#$0099'+öXM'#$D'ÿ¡TÍA'#$009C'Ç$'#$008F'!F'#0'ª{"Þ#R®øØù'#$009C'EE'#$009C'S1©PTÅ'#$009A'¨V'#8'$²&'#$13'ü@¬jbµLu'#$0089'Â\q0>?u|¦¦9IVT¶â'#$D'í'#$1E'{}'#$009B#$00AD#$15'ÿ'#1'Ç'#$009A'm'#$0098
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #5 on: February 24, 2021, 10:08:59 AM » |
|
You must have Encryption and/or Compression enabled on your TRtcClientModule and/or TRtcServerModule component. If you want to disable both, so that plain text would be sent and received (not compressed or encrypted), check the following properties on your TRtcClientModule and TRtcServerModule components and make sure they have these values assigned (default):
Compression = cNone EncryptionKey = 0 EncryptionMode = rem_Basic RSAKey = 0 SecureKey = '' // this should be an empty string ForceEncryption = False
Encryption and Compression work on binary data (byte arrays) and should NOT change the actual content, so your Unicode characters should remain, regardless of compression/encryption usage. Once you find out where your characters are being modified, you can turn compression and/or encryption back on.
Best Regards, Danijel Tkalcec
|
|
|
Logged
|
|
|
|
bikotronic
|
|
« Reply #6 on: February 24, 2021, 11:50:56 AM » |
|
thx, i send a test string like and receive this 'ABCDEFG1234ÖÄÜöäüß'#$0080'@' #$0080 is a unicode char for the € i send a test string like and receive this
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #7 on: February 24, 2021, 12:04:44 PM » |
|
How exactly do you send and how exactly do you receive that string?
|
|
|
Logged
|
|
|
|
bikotronic
|
|
« Reply #8 on: February 24, 2021, 01:37:10 PM » |
|
uses rtcCliModule, rtcHttpCli, rtcFunction, rtcInfo, rtcConn, rtcTypes, rtcSystem; fClientModule : TRtcClientModule; fClient : TRtcHttpClient; on FormCreate fClientModule:=TRtcClientModule.Create(self); with fClientModule do begin Name :='fClientModule'; Client :=fClient; AutoSessions :=true; AutoSyncEvents :=true; AutoRepost :=0; OnResponseAbort:=OnClientModuleResponseAbort; Compression := cNone; EncryptionKey := 0; EncryptionMode := rem_Basic; RSAKey := 0; SecureKey := ''; // this should be an empty string ForceEncryption := False; DataFormat :=TRtcDataFormat; ModuleFileName :='/$MSG'; ModuleHost :='127.0.0.1' end;
send msg procedure SendMsg; begin with fClientModule, Data.NewFunction('SendMsg') do begin asText['msg'] :='Демпфирование'; Call(fSendMsgResult); end; end;
receive procedure OnGetMsgResultReturn(Sender: TRtcConnection;Data: TRtcValue; Result: TRtcValue); var s : string; begin s:=Result.asText; //test --> wrong charset !!!
if Result.isType=rtc_Exception then begin
end;
if Result.asString=resError then begin Logout; exit; end;
if Assigned(FOnGetMsg) then FOnGetMsg(Result); end;
procedure fOnGetMsg(Sender: TObject); var aMsg: string; begin if TRtcValue(Sender).isType = rtc_Record then begin aRecord := TRtcValue(Sender).asRecord; if assigned(aRecord) then begin aMsg := aRecord.asText[aKEY]; end; end; end;
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #9 on: February 24, 2021, 01:44:06 PM » |
|
This is your Client-side code. The content you send from the Client should be sent to the Server, from where the Server should send a response back to the Client, but I don't see your Server-side code here.
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #10 on: February 24, 2021, 02:01:04 PM » |
|
Also, make sure to save your Delphi files (.PAS and .DFM) in a Unicode file format. Otherwise, Unicode characters used in your Source Code (as in your example above) would ONLY appear correctly on your development machine because of your Windows code-page, but would actually be handled as ANSI characters and would be lost in the transfer.
|
|
|
Logged
|
|
|
|
bikotronic
|
|
« Reply #11 on: February 24, 2021, 02:03:48 PM » |
|
ServerLink: TRtcDataServerLink; Module: TRtcServerModule; Module.Compression := cNone; Module.EncryptionKey := 0; Module.SecureKey := ''; // this should be an empty string Module.ForceEncryption := False; DataFormats = [fmt_RTC, fmt_XMLRPC] group this --> MsgFunctions: TRtcFunctionGroup; link --> ServerLink MsgSendMsg: TRtcFunction; group: MsgFunctions -- on execute --> this procedure MsgSendMsgExecute(Sender: TRtcConnection;Param: TRtcFunctionInfo; Result: TRtcValue); var s : String; begin result.asString:=resError; s:=Param.asText['msg']; result.asString:=s; end;
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #12 on: February 24, 2021, 02:06:07 PM » |
|
What is this?
var s : String; begin result.asString:=resError; s:=Param.asText['msg']; result.asString:=s;
Why are you using "asString" to assign the Unicode text received from "Param.asText" here, instead of using "asText", as I've advised? Also, why are you assigning "resError" to "Result.asString"? That makes absolutely no sense. My guess is that this is what you actually wanted to do ...
procedure MsgSendMsgExecute(Sender: TRtcConnection;Param: TRtcFunctionInfo; Result: TRtcValue); var s : String; begin s:=Param.asText['msg']; result.asText:=s; // I am using "asText" here (not "asString") to make sure the Unicode text is encoded correctly. end;
|
|
|
Logged
|
|
|
|
bikotronic
|
|
« Reply #13 on: February 25, 2021, 03:36:07 PM » |
|
uuppsss shit happens, thx for the support now it works fine changed all .asString to .asText
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #14 on: February 25, 2021, 03:40:45 PM » |
|
You're welcome. Thanks for the feedback.
|
|
|
Logged
|
|
|
|
|