how to replace char with other in hexdecimal - replace

I'm a new user who using mainframe, I have a file and I need to change all dots '.' in file with space, I was trying to write this statement on command
change X'05' X'40' all
after I converted the file to hexdecimal, but It doesn't work.
How can I change all the dots with space in file, in simple way please?

The dots are non-displayable characters. You can match them using picture strings in the ISPF editor (which is what I assume you're trying to use to edit the file?)
Try the command
change p'.' ' ' all
The "p'.'" part will match any non-displayable character and change it to a blank.

Hans answer above will certainly change any non-displayable character to a space. However you need to make sure you really want to change all non displayable characters to a space. Turn HEX ON to look at the actual data. You can then do a F p'.' to find the non-displayable character(s) prior to changing it. Browse shows non-displayable characters as a dot. However Edit would replace the value with an attribute for display purposes and this keeps you from typing over the data. You have to turn on HEX mode to manually modify the non-displayable value or use the Change command as you were trying. Typically any hex value from x'00' - x'3F' would be non-displayable. So a
C P'.' X'40' ALL
would modify every one of those values to a space. This may or may not be desirable depending on the file.

Related

How does the escape sequence '\b' work in C++? Alternate display method?

So I've outputted a string of various ASCII characters. This program involves parts of this string being modified, and then re-displayed.
Instead of clearing the entire screen and re-displaying everything, which produces an unwanted flicker effect, I've decided on moving the cursor and then rewriting only the characters that have changed.
I'm moving the cursor with SetConsoleCursorPosition, part of windows.h.
However, once I try and cout something, it pushes all of the text in front of it ahead by a space; another unwanted effect.
In an attempt to fix this, I tried various forms of 'cout<<"\b";' to remove the old, unmodified character. But there was either no effect, or it actually added a space, which is obviously not a desired effect here.
I read somewhere that in order to remove the unwanted character that you actually have to use the escape sequence twice, Example: '\b\b', because the first one moves the cursor back a space, and the second one overwrites the character in front of it with a space (' ') or something like that.
'\b\b' didn't work either, unsurprisingly. Or maybe that is surprising, I don't actually know.
My question is: How do I remove the unwanted character? Or better yet, How do I overwrite text that has already been outputted with new text?
EDIT: I apologize, I'm running Windows 7
I think maybe clearing the ENABLE_INSERT_MODE with the SetConsoleMode function might help. It should prevent the console from inserting characters and pushing the old characters forward.

I see a character called xDB on notepad++. What character is this?

What is this character
All I really need to know is what is this character. I have not seen anything like this before.
How do i remove this using Vb.net:
data = data.Replace(Chr(???????), "")
Is there a specific control character decimal number or something to this character that i can use in place of ??
Please help.
I tried looking up all the html, ascii and the regex languages to find this character but i did not find this anywhere.
To prevent possible bugs related to the encoding of your source files, you should use a hex editor (such as this Notepad++ plugin) to find the hexadecimal code of the character, then use that to reference the character in your code:
data = data.Replace((char)0xDB, "")
as opposed to:
data = data.Replace("Û", "")
Note: In this case the hex editor is unnecessary because xDB is already a hex code, but other control characters, such as CR and LF, are not displayed as their hex values [in Notepad++].

How to detect a tab in a text file?

Is detecting tabs same as detecting the spaces? i.e. for detecting a space, I would just compare the space character with its ascii number.
For a tab do I have to search for '\t' character in the file or there is some other way?
if('\t' == myChar)
This would work, and would be better than checking against 9 since 9 may not be a guaranteed value across all architectures.
Assuming you are working with ASCII data, you can just search for a byte with value '\t' (9) in the text file. Tabs are represented as a single byte in text files and most libraries for reading files don't do anything special with those bytes.
A tab is just another character so you can check for the ASCII value if you want.
Although a tab appears as 4 or 8 spaces in an editor, it is actually represented as a single character ('\t', like you mentioned) inside a file. Both the space character and the tab character take up one byte. So basically, u are correct in your assumption.

Delimiting Character

We are loading a Fixed width text file into a SAS dataset.
The character we are using to delimit multi valued field values is being interpreted as 2 characters by SAS. This breaks things, because the fields are of a fixed width.
We can use characters that appear on the keyboard, but obviously this isn't as safe, because our data could actually contain those characters.
The character we would like to use is '§'.
I'm guessing this may be an encoding issue, but don't know what to do about it.
Could you use the keycode for the character like DLM='09'x and change 09 to the right keycode?

ASCII Value for Nothing

Is there an ascii value I can put into a char in C++, that represents nothing? I tried 0 but it ends up screwing up my file so I can't read it.
ASCII 0 is null. Other than that, there are no "nothing" characters in traditional ASCII. If appropriate, you could use a control character like SOH (start of heading), STX (start of text), or ETX (end of text). Their ASCII values are 1, 2, and 3 respectively.
For the full list of ASCII codes that I used for this explaination, see this site
Sure. Use any character value that won't appear in your regular data. This is commonly referred to as a delimited text file. Popular choices for delimiters include spaces, tabs, commas, semi-colons, vertical-bar characters, and tilde.
In a C++ source file, '\0' represents a 0 byte. However, C++ strings are usually null-terminated, which means that '\0' represents the end of the string - which may be what is messing up your file.
If you really want to store a 0 byte in a data file, you need to use some other encoding. A simplistic one would use some other character - 0xFF, for example - that doesn't appear in your data, or some length/data format or something similar.
Whatever encoding you choose to use, the application writing the file and the one reading it need to agree on what the encoding is. And that is a whole new nightmare.
The null character '\0' still takes up a byte.
Does your software recognize the null character as an end-of-file character?
If your software is reading in this file, you can define a place holder character (one that isn't the same as data) but you'll also need to handle that character. As in, say '*' is your place-holder. You will read in the character but not add it to the structure that stores your data. It will still take up space in your file, but it won't take up space in your data structure.
Am I answering your question or missing it?
Do you mean a value you can write which won't actually change the file? The answer is no.
Maybe post a little more about what you're trying to accomplish.
it would depend on what kind of file it is and who is parsing it.