EldoS | Feel safer!

Software components for data protection, secure storage and transfer

XML Sig and Encoding problem

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#15388
Posted: 12/28/2010 06:29:29
by Haris Zujo (Standard support level)
Joined: 05/12/2006
Posts: 33

Hi Eldos,

I'm back with the question regarding UTF-8 encoding and XML dsig.
I'm using "SecureBlackbox - VLC version 8.1.192 - Released December 10, 2010"



I have the following XML document.

Code
<?xml version="1.0" encoding="UTF-8"?>
<Message>
  <Body>
    <Data>
      <CD815A>
        <Body>
          <SubmittedDraftOfEaad>
            <FirstTransporterTrader>
              <VatNumber>1</VatNumber>
              <TraderName>ÃÎÑÏÎÄÀÐÑÊÈ ÑÓÁ£ÅÊÒ</TraderName>
              <StreetName>óëèöà &#269;&#268; &#263;&#262; &#273;&#272; &#353;&#352; &#382;&#381;</StreetName>
              <StreetNumber>37</StreetNumber>
              <Postcode>1000</Postcode>
              <City>ë¼óáë¼àíà ÷÷ ææ øø</City>
            </FirstTransporterTrader>
          </SubmittedDraftOfEaad>
        </Body>
      </CD815A>
    </Data>
    <Signatures/>
  </Body>
</Message>


These strange characters are all in UTF-8 but some of them are already in the creation of 'TElXMLDOMDocument' (before signing) lost. So the document is no longer what it used to be!

Here is the part of code that loads the string into 'TElXMLDOMDocument' object.
Code
procedure LoadXMLDocumentFromString(var Doc: TElXMLDOMDocument; const Xml: String);
var
  S: TStringStream;
begin
  if Doc = NIL then
    Doc := TElXMLDOMDocument.Create();

  S := TStringStream.Create(Xml);
  // ^^^^^^^^ In Stream 'S' the characters are OK
  
  try
    Doc.LoadFromStream(S, 'utf-8', true);
   // ^^^^^^ Now they are LOST!
  finally
    FreeAndNil(S);
  end;
end;


Nad after that I got:

Code
<?xml version="1.0" encoding="utf-16"?><Message>
  <Body>
    <Data>
      <CD815A>
        <Body>
          <SubmittedDraftOfEaad>
            <FirstTransporterTrader>
              <VatNumber>1</VatNumber>
              <TraderName>??????????? ???????</TraderName>
              <StreetName>????? &#269;&#268; &#263;&#262; &#273;&#272; &#353;&#352; &#382;&#381;</StreetName>
              <StreetNumber>37</StreetNumber>
              <Postcode>1000</Postcode>
              <City>????????? ?? ?? ??</City>
            </FirstTransporterTrader>
          </SubmittedDraftOfEaad>
        </Body>
      </CD815A>
    </Data>
    <Signatures/>
  </Body>
</Message>


Only latin characters are still in the document all cyrillic characters are replaced with questionmark!
I'm attaching the document for easyer investigation!
I need some help. Thanks

btw: I can't compile "/samples/delphi/XMLBlackbox/Signer/SimpleSigner.dpr" because there is no "SBHTTPSClient, SBHTTPTSPClient,SBHTTPCRL, SBHTTPOCSPClient" units in my download package!


[ Download ]
#15389
Posted: 12/28/2010 06:46:58
by Eugene Mayevski (EldoS Corp.)

Haris, I'm moving your post to HelpDesk because here it's creating a mess - three different topics in one are not very readable. New topic started would be better, but let's continue in HelpDesk.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 6108 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!