DcXml Encoding options

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
PedroAlex
Posts: 229
Joined: Tue Feb 09, 2010 3:06 am

DcXml Encoding options

#1 Post by PedroAlex »

Roger,

DcXml it is a great tool and I use it very often.

sometimes I need to change the encoding.
however the function DC_XmlNode:WriteXML is predefined to use "windows-1252".

I sugest this improvement for this Method (if you agree):

Code: Select all

METHOD DC_XmlNode:WriteXML( cFileName, lCanon, lSuppressIndent, nOption )

LOCAL nHandle
nHandle := FCreate(cFileName)
IF nHandle <= 0
  RETURN .F.
ENDIF
IF nOption == 1
    FWrite(nHandle,'<?xml version="1.0" encoding="UTF-8"?>'+CRLF)
ELSE
	FWrite(nHandle,'<?xml version="1.0" encoding="windows-1252"?>'+CRLF)
ENDIF
::writeNode( nHandle,lCanon,lSuppressIndent)
FClose(nHandle)

RETURN .T.
Or you have another solution?

Thanks..
Pedro Alexandre

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DcXml Encoding options

#2 Post by rdonnay »

Yes, I agree.

I made the change to my source code.

BTW - The original code WAS UTF-8.
The eXpress train is coming - and it has more cars.

messaoudlazhar
Posts: 42
Joined: Mon Dec 23, 2013 2:10 pm
Contact:

Re: DcXml Encoding options

#3 Post by messaoudlazhar »

I suggest function to this :

Code: Select all

METHOD DC_XmlNode:WriteXML( cFileName, lCanon, lSuppressIndent, cEncodage )

LOCAL nHandle
DEFAULT cEncodage TO 'UTF-8'
nHandle := FCreate(cFileName)
IF nHandle <= 0
  RETURN .F.
ENDIF
FWrite(nHandle,'<?xml version="1.0" encoding="'+cEncodage+'"?>'+CRLF)
::writeNode( nHandle,lCanon,lSuppressIndent)
FClose(nHandle)

RETURN .T.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DcXml Encoding options

#4 Post by rdonnay »

That's better.
The eXpress train is coming - and it has more cars.

Post Reply