Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Module Information
Public.Standards.XML
Viewing contents of Public_Standards_XML-0.1/module.pmod.in

string __version = "0.1";
string __author = "Bertrand LUPART ";
array __components = ({ "Public.pmod/Standards.pmod/XML.pmod/module.pmod" });

constant NUMERIC_HEX = 1;


//! Encodes numerical entities. Default to dec.
//! > Public.Standards.XML.encode_numeric_entity("pike");
//! (1) Result: "pike"
//! > Public.Standards.XML.encode_numeric_entity("pike", Public.Standards.XML.NUMERIC_HEX);
//! (2) Result: "pike"
//!
//! @param from
//! The string to be encoded
//!
//! @returns
//! The encoded string
string encode_numeric_entity(string from, void|int type)
{
	if(type && intp(type) && type==NUMERIC_HEX)
		return encode_numeric_entity_hex(from);
	return encode_numeric_entity_dec(from);
}


//! Encodes numerical entities to hex.
//! > Public.Standards.XML.encode_numeric_entity_hex("pike");
//! (1) Result: "pike"
//!
//! @param from
//! The string to be encoded
//!
//! @returns
//! The encoded string.
string encode_numeric_entity_hex(string from)
{
  string to = "";
  foreach(from; int index; string value)
    to+=sprintf("&#x%x;", value);
  return to;
}


//! Encodes numerical entities to dec.
//! > Public.Standards.XML.encode_numeric_entity_dec("pike");
//! (1) Result: "pike"
//!
//! @param from
//! The string to be encoded
//!
//! @returns
//! The encoded string.
string encode_numeric_entity_dec(string from)
{
  string to = "";
  foreach(from; int index; string value)
    to+=sprintf("&#%d;", value);
  return to;
}


gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University