Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

The Source Code Exporter Backslash Problem

(1/1)

NanoBytes:
Im not sure if this topic has already been dicussed here, but im new (i made the account just to tell you guys this) I was exporting the code from one of my projects in RTF format. every time it came across a backslash character it screws up (Not because of the exporter, but because of RTF format) if the \ token is unrecognized it will simply ingore it.
eg. "Hello\0 World" would become "Hello0 World"
And it gets realy messed up with other characters such as \' or \"
BUT double backslashes work fine "Hello\\0 World" becomes "Hello\0 World"
And that is how it should be displayed, but that wont work in code

The solution is simple enough though, all you have to do is put a recognized in the RTF exporter. If the current character is a backslash simply output it twice

outputRTFChar(currentChar);
if (currentChar == '\\') outputRTFChar(currentChar);

MortenMacFly:

--- Quote from: NanoBytes on August 14, 2011, 01:19:02 am ---outputRTFChar(currentChar);
if (currentChar == '\\') outputRTFChar(currentChar);

--- End quote ---
This is not as simple as it sounds, have a look at RTFExporter::RTFBody(...) - the whole content is converted at once, not char-by-char. However, it's surely do-able. Can you provide a patch accordingly, please?

seb_seb0:
I have done a small patch here.
It works with output of "Hello\0 World".

In
--- Code: ---RTFExporter::RTFBody
--- End code ---
, there is a switch over each character from the memory buffer. I have simply added a case:

--- Code: ---      case '\\':
        {
            rtf_body += string("\\\\");
        }
        break;

--- End code ---

I have made a test of a 2000 lines file, and it works OK for me.

Seb

NanoBytes:
Hey, Im not sure how to get your patch to work with code blocks, I have no ide where to start actualy. So could one of you simply post the Exporter.dll, or you could teach me how to use the .patch that you already posted, but the later is inpreferable.

MortenMacFly:

--- Quote from: NanoBytes on September 05, 2011, 04:22:17 am ---Hey, Im not sure how to get your patch to work with code blocks, I have no ide where to start actualy. So could one of you simply post the Exporter.dll, or you could teach me how to use the .patch that you already posted, but the later is inpreferable.

--- End quote ---
Wait for the net nightly. It will have this implemented.

Navigation

[0] Message Index

Go to full version