Can we keep std.xml : encode, decode ?

WebFreak001 d.forum at webfreak.org
Mon Jul 20 14:04:57 UTC 2020


Whenever operating with any XML files, even if not using the 
std.xml API, I very often use encode/decode to insert strings 
into fixed file templates.

I think a lot of people will have used and still use these APIs 
because they are in the standard library and very trivial short 
implementations you can expect to exist. I think for these two 
small functions pulling in a dub library is overkill and often 
will not work well for script-like D files.

`std.xml` is being removed for being considered "out-dated and 
not up to Phobos' current standards", however I believe the 
encode/decode functions are close enough to the current standards 
or can be fairly easily modified or reimplemented to meet them.

I believe putting the XML parser, DOM & serializer from std.xml 
into undeaD is a good idea, however I think the very basic string 
utilities that many more programs might use should stay in.

For example currently some simple script that is called in a 
cronjob could be used to automatically generate a static HTML 
file given some input from some other program:

import std.conv;
import std.stdio;
import std.xml : encode;

void main(string[] args)
{
	writeln("<!DOCTYPE html><html>");
	writeln("<head><title>Auto generated site</title></head>");
	writeln("<body>");
	writeln(`<h1 title="`, args.to!string.encode, `">`);
	writeln("Last call: ", args.to!string.encode);
	writeln("</h1>");
	writeln("</body></html>");
}



More information about the Digitalmars-d mailing list