-
October 29th, 2010, 05:56 AM
#1
STX \x02 character in code editor?
Any ideas how to get to show in VC++ 2010 Express?
Ive got a few strings that use it to split them, "sometextsometextmaybenumbers242423424etc", but if I paste it into the code editor in VC++, it basically becomes invisible, its still there, you can use the arrow to move past it, but it just takes up no space. So, the text ends up looking like "sometextsometextmaybenumbers234234234".
Any way to make the actually show up? In SciTE it comes up with {STX} in place of it, but yeah, nothing in VC++.
-
October 29th, 2010, 06:30 AM
#2
Re: STX \x02 character in code editor?
\x02 is not a ascii char, so no, you will not see it in a editor. What you can do is preparse the data yourself and replace the char-code \x02 with actual text '\x02'.
Last edited by Skizmo; October 29th, 2010 at 07:06 AM.
-
October 29th, 2010, 08:33 AM
#3
Re: STX \x02 character in code editor?
Currently ive been doing something like
Code:
std::string STX = "\x02";
std::stringstream data;
data << "sometext" << STX << "sometextetcetc" << STX << "12342342sdfsdf";
But yeah, when it gets more data in it, it tends to look ugly and confusing to go through.
Unless you know of a better way, string replace of some sort?
-
February 23rd, 2014, 10:14 PM
#4
Re: STX \x02 character in code editor?
1. \x02 is the second character in ASCII Characters. It is a Control Characters. It means "start of text". So, it could not be printed.
2. The UI in Visual Studio 2010 uses WPF, including code editor. The WPF use FontFamily to render its glyph. And if a character's code could not be found in the font you set, the fallback mechanism will be invoked. WPF will assign a default font to substitute. However, the x\02 is not in any Font. So, it will be invisible.
3. The UI in Visual Studio 2008 uses Font rather than FontFamily. There is no fallback mechanism. So, sometimes you may see a strange character in some font for \x02, like Tahoma Font.
4. The SciTE is the best practice.
As a result, you could just paste that character in the code editor. And render it with {STX} in your product.
Wish it helpful.
-
February 24th, 2014, 07:40 AM
#5
Re: STX \x02 character in code editor?
Originally Posted by azkay
Code:
data << "sometext" << STX << "sometextetcetc" << STX << "12342342sdfsdf";
This has the disadvantage that "behind the scenes" results in 5 function calls.
that may or may not be an issue for your code.
Code:
data << "sometext\x02sometextetcetc\x0212342342sdfsdf";
is only a single function call.
You could also use C++ literal string catenation (=compile time) and do:
Code:
#define STX "\x02"
data << "sometext" STX "sometextetcetc" STX "12342342sdfsdf";
which compiles to exactly the same as above.
-
February 24th, 2014, 07:44 AM
#6
Re: STX \x02 character in code editor?
Also: enforcing control codes in literal C++ strings (via an editor that supports it, or via hex-editing) may cause "strange effects" in the compilers (depending on the compiler). So even if you can do it in an editor, it's probably still a bad idea.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|