in reply to How do I mark the end of a file?
The '^@'s you are seeing, presumable in some text editor, are most likely actually null bytes (ascii 0). In the same way that ascii 1 is sometimes represented as '^A' and ascii 3 as '^C'. That is to say, the editor or viewer you are using to inspect the file is performing a translation of 'invisible' ascii values below ascii 32 and representing them as a '^' followed by a visible character derived by adding 0x40 to the actual ascii value. Hence the two ascii chars ^@ are used to designate the original ascii 0 value.
Ascii 0 does not match the regex \s+, so your code is failing to remove them. If you substitute (\0+) for (\s+) in your regex, your code will probably do what you want.
|
|---|