XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Phil Shafer
phil at juniper.net
Wed Aug 13 19:37:10 UTC 2014
Phil Shafer writes:
>FWIW, the UTF-8 strategy for libox is this:
>- all format strings are UTF-8
>- argument strings (%s) are UTF-8
>- "%ls" handles wide characters
>- "%hs" will handle locale-based strings
>- XML, JSON, and HTML will be UTF-8 output
>- text will be locale-based
Sorry for the delay, but this code is now done. Formatting widths
are done using wcwidth() so things like "%15.15s" work correctly
regardless of locale settings. As a background task, I'm converting
some basic commands to use libxo. It's slow work, but needs done....
I've a related topic: when an app goes to run a child command, how
can it determine whether that binary supports libxo-based encoding
requests? This should be known before the binary is run, since
there's no means of auto-detecting the supported output after the
fact.
For example, say I want to make a JSON-based API for my server. I
can setenv("LIBXO_OPTIONS", "json") to get JSON output, but I won't
know if the binary supports this or if the output needs to be wrapped
and escaped.
I know ELF "Note" elements can be used to carry vendor-specific
data, but have no experience with them. Would it be reasonable to
use them as a means of communicating this information to other bits
of software? Is FreeBSD using Notes for other information currently?
Thanks,
Phil
P.s.: Attached is a screenshot of a quick demo using netstat output
rendered in HTML with the jquery qtip popup that shows the XPath,
along with some firebug output to show the contents. (The "data-qtip"
attribute is added dynamically by the qtip library.)
More information about the freebsd-arch
mailing list