Recent

Author Topic: WideString to AnsiString conversion warning  (Read 382 times)

dodgebros

  • Full Member
  • ***
  • Posts: 110
WideString to AnsiString conversion warning
« 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

dsiders

  • Sr. Member
  • ****
  • Posts: 388
Re: WideString to AnsiString conversion warning
« Reply #1 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.

Lazarus 2.1 (SVN) / FPC 3.0.4 / FPC 3.2.0 / x86-win64 / Windows 8.1

Bart

  • Hero Member
  • *****
  • Posts: 4045
    • Bart en Mariska's Webstek
Re: WideString to AnsiString conversion warning
« Reply #2 on: September 29, 2020, 11:23:23 pm »
Isn't DomString an alias for WideString (not AnsiString)?

Bart
« Last Edit: September 29, 2020, 11:39:14 pm by Bart »

dsiders

  • Sr. Member
  • ****
  • Posts: 388
Re: WideString to AnsiString conversion warning
« Reply #3 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.
« Last Edit: September 30, 2020, 09:41:28 am by dsiders »
Lazarus 2.1 (SVN) / FPC 3.0.4 / FPC 3.2.0 / x86-win64 / Windows 8.1

PascalDragon

  • Hero Member
  • *****
  • Posts: 2433
  • Compiler Developer
Re: WideString to AnsiString conversion warning
« Reply #4 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