Lazarus

Programming => General => Topic started by: dodgebros on September 29, 2020, 08:33:17 pm

Title: WideString to AnsiString conversion warning
Post by: dodgebros on September 29, 2020, 08:33:17 pm
I have several of the "WideString to AnsiString" conversion warnings whenever the app is run from the IDE. 

Originally I had this and that is when I get the warning:

Code: Pascal  [Select][+][-]
  1.    strMDBHortDB: String;
  2.  

Here I am trying to determine which data type the TDOMNode returns:

Code: Pascal  [Select][+][-]
  1. var
  2.   strMDBHortDB: variant;
  3.   MyNode: TDOMNode;
  4.  
  5.                     strMDBHortDB := MyNode.FirstChild.NodeValue;
  6. showmessage(VarToStr(varType(DataModule1.strMDBHortDB)));
  7.  

 The showmessage() shows the number 8.  What is data type 8? 

TD
Title: Re: WideString to AnsiString conversion warning
Post by: dsiders on September 29, 2020, 09:45:21 pm
I have several of the "WideString to AnsiString" conversion warnings whenever the app is run from the IDE. 

Originally I had this and that is when I get the warning:

Code: Pascal  [Select][+][-]
  1.    strMDBHortDB: String;
  2.  

Here I am trying to determine which data type the TDOMNode returns:

Code: Pascal  [Select][+][-]
  1. var
  2.   strMDBHortDB: variant;
  3.   MyNode: TDOMNode;
  4.  
  5.                     strMDBHortDB := MyNode.FirstChild.NodeValue;
  6. showmessage(VarToStr(varType(DataModule1.strMDBHortDB)));
  7.  

 The showmessage() shows the number 8.  What is data type 8? 

TD

That would be varOleStr (since you used Variant for variable).

TDomNode.NodeValue is declared as a DOMString which is an alias for AnsiString. It is always a string value because everything is stored as character values in XML elements and attributes.

You'll need to look at NodeName and NodeTtype to determine what type of data the NodeValue actually represents.

Title: Re: WideString to AnsiString conversion warning
Post by: Bart on September 29, 2020, 11:23:23 pm
Isn't DomString an alias for WideString (not AnsiString)?

Bart
Title: Re: WideString to AnsiString conversion warning
Post by: dsiders on September 30, 2020, 08:05:32 am
Isn't DomString an alias for WideString (not AnsiString)?

Bart

Not in the LazUtils version of laz2_do,pas. The FPC varsion in dom.pp uses XMLString which is an alias for UnicodeString.
Title: Re: WideString to AnsiString conversion warning
Post by: PascalDragon on September 30, 2020, 09:41:46 am
Not in LazUtils version.

In the one provided with FPC (starting from 3.2.0) DOMString, or more precisely XMLString is aliased to UnicodeString (before that it was WideString).
TinyPortal © 2005-2018