473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

escape character in XML text string

Hi,

I am generating a XML based file for a system that will generate PCL code
from textual <text>..</text> tag items. The PCL string needs escape
characters. The string within this tag will be transparently forward to a
device that understands escape characters.

How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.

char c = '\u001b';
string = "ab" + c + "de" will not work.

Any ideas?

Gr. Ricardo

Jul 20 '05 #1
7 10185
* Te********@intervisit.com wrote in comp.text.xml:
I am generating a XML based file for a system that will generate PCL code
from textual <text>..</text> tag items. The PCL string needs escape
characters. The string within this tag will be transparently forward to a
device that understands escape characters.

How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.


You cannot include U+001B literally in XML documents, you need some
method to express U+001B in characters that are allowed in XML. In
common use are Base64 and Hex encoding.
Jul 20 '05 #2
On Wed, 21 Jan 2004 21:44:07 GMT, "Te********@intervisit.com"
<te********@intervisit.com> wrote:
How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.


Tried an entity ?


Jul 20 '05 #3
Andy Dingley wrote:
On Wed, 21 Jan 2004 21:44:07 GMT, "Te********@intervisit.com"
<te********@intervisit.com> wrote:

How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.

Tried an entity ?




Tried yourself?

Anyway: doesn't work. The character is illegal in XML, no matter whether
as entitiy or not.
Jul 20 '05 #4
On Thu, 22 Jan 2004 10:35:33 +0100, Julian Reschke
<ju************@gmx.de> wrote:
Anyway: doesn't work. The character is illegal in XML, no matter whether
as entitiy or not.


Sorry - gettiing late and I was tired. It's in the forbidden range
(I've never understood why - anyone care to explain the reasoning
behind them ?)

Jul 20 '05 #5
Andy Dingley wrote:
On Thu, 22 Jan 2004 10:35:33 +0100, Julian Reschke
<ju************@gmx.de> wrote:

Anyway: doesn't work. The character is illegal in XML, no matter whether
as entitiy or not.

Sorry - gettiing late and I was tired. It's in the forbidden range
(I've never understood why - anyone care to explain the reasoning
behind them ?)


Escape sequences are used to control output devices, eg to change fonts,
clear the screen, switch to block graphics mode, and goddess knows what
else.

You really, *really*, REALLY don't want ESC in your output stream, ever,
unless you are writing a device controller.

The OP wanted to use an XML stream for device control, which IMHO is
A Bad Idea. The simple solution is to insert a placeholder like <ESC/>
and pass the file through a transformation stage that *will* output
a \027 character.

///Peter

Jul 20 '05 #6
On Sat, 24 Jan 2004 02:21:44 +0000, Peter Flynn <pe***@silmaril.ie>
wrote:
You really, *really*, REALLY don't want ESC in your output stream, ever,
unless you are writing a device controller.


But what if I am ?

 is a good "XML-like" solution to handling these potentially
volatile characters. Represented as an entity, it ain't going nowhere
(equally for your <ESC/> example).

Expanding the entities (&amp; as an example) already transforms the
input from well-formed XML to something else. I don't see the possible
presence of \027 in here as any more risky than a serial cable's
ability to carry that same octet.

Jul 20 '05 #7
Andy Dingley wrote:
On Sat, 24 Jan 2004 02:21:44 +0000, Peter Flynn <pe***@silmaril.ie>
wrote:

You really, *really*, REALLY don't want ESC in your output stream, ever,
unless you are writing a device controller.

But what if I am ?

 is a good "XML-like" solution to handling these potentially
volatile characters. Represented as an entity, it ain't going nowhere
(equally for your <ESC/> example).

Expanding the entities (&amp; as an example) already transforms the
input from well-formed XML to something else. I don't see the possible
presence of \027 in here as any more risky than a serial cable's
ability to carry that same octet.


In fact, generating *XML* and sending it directly to a device that
expects ESCs makes little sense. However, it's perfectly plausible to
use XSLT's text output method to produce this kind of output. Right now,
this doesn't work out-of-the-box.

One approach is to define placeholders such as <esc/> and have a special
output method to translate those (I think many Java based XSLT engines
allow you to define custom output methods).

This issue may also get solved by XML 1.1
(<http://www.w3.org/TR/xml11/#sec-xml11>). Is anybody aware of changes
in XSLT 2.0?

Julian
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alden Streeter | last post by:
Here is the HTML that is being output by my asp page: <a href='Files/category/computers/bigimages/computers-sub-monitors.jpg' target='_blank' onMouseOver="window.status='Click for a larger image...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
4
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> ...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
6
by: sloan | last post by:
I have a fairly simple RegEx code below. I am given a file name, (which I don't control) , and need to change a folder name in it. The code below is choking on the filename not being...
3
by: qilin | last post by:
I am trying to save a big text string into MySQL, but I guess i need escape the string firstly, anybody knows any escape function in c for that? or any other suggests ?
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.