Troubleshooting
Problem
Attempts to export text that contains the backslash character \ using IBM Rational DOORS rich text in string function in combination with .text results in double backslash characters \\ in the output.
Symptom
The DXL output is returning two backslashes for every one backslash contained in the text.
Steps to reproduce:
Run the following DXL for an open module that contains an object with a backslash in the text:
Object o
for o in current Module do {
string rts = richText( o."Object Text" )
RichText rt
for rt in rts do {
string plainText = rt.text
print plainText "\n"
}
}[</code>]
Expected results: A single backslash is rendered in the output.
Actual results: Two backslashes are rendered in the output (see image below).
image
![](/support/pages/system/files/support/swg/rattech.nsf/0/f0b2ec525b2e4712852579b80066648e/Symptom/0.4D8.gif)
Cause
For text that contains file path locations stored in a DOORS attribute, the exported information will not let you get to the file.
Diagnosing The Problem
Verify the issue:
- Create a Wordpad document
- Insert a single backslash \
- Save document as RTF file
- Open the Wordpad document in Notepad to see its RTF markup
You will notice that the single backslash entered is actually stored after being escaped with another
backslash ( \\ double-slash).
Example: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22\\\par
}
Resolving The Problem
This is expected behavior.
By convention, the backslashes are stored in the actual RTF markup as escaped (inserted backslash) so that any RTF reader cannot mix them up as part of the RTF syntax.
So when you get the rich text version of a string that contains a backslash, it gives you what it actually stored which is \\ for a single slash.
If you print the object text as plain text, it is shown as a single slash.
Was this topic helpful?
Document Information
Modified date:
01 May 2020
UID
swg21586745