Questions tagged [nul]

NUL is the abbreviation for the null character in several character sets

NUL has a value of 0 and is often written as the escape sequence \0. It is used as a terminator in standard strings.

167 questions
34
votes
5 answers

Java string replace and the NUL (NULL, ASCII 0) character?

Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII characters. Taking a dip into the source I found this tidbit: // remove any periods from first name e.g. Mr. John --> Mr John firstName =…
praspa
  • 604
  • 2
  • 7
  • 12
22
votes
2 answers

C# Generics: If T is a return type, can it also be void? How can I combine these interfaces together?

I have the following interface that returns the generic parameter of type T using a callback... public interface IDoWork { T DoWork(); } however I also have the following interface as well, but it won't invoke a callback since it returns…
halfbit
  • 54,462
  • 46
  • 195
  • 426
21
votes
1 answer

nul bytes in regexp MATLAB

Can someone explain what MATLAB is doing with nul bytes (x00) in regular expressions? Examples: >> regexp(char([0 0 0 0 0 0 0 1 0 0 10 0 0 0]),char([0 0 0 0 46 0 0 10])) ans = 1 % current 4 % expected >> regexp(char([0 0 0 1 0 0 0 1 0…
horriblyUnpythonic
  • 823
  • 13
  • 32
20
votes
4 answers

Is '\0' guaranteed to be 0?

I wrote this function in C, which is meant to iterate through a string to the next non-white-space character: char * iterate_through_whitespace(unsigned char * i){ while(*i && *(i++) <= 32); return i-1; } It seems to work quite well, but…
Paul
  • 130,653
  • 24
  • 259
  • 248
17
votes
4 answers

Passsing null byte via format specifier in `printf`

Why does printf print a space instead of stopping when I use the NULL character from the ASCII table? This is what I mean: printf("Hello%c, world", 0); //Hello , world printf("Hello%c, world", '\0'); //Hello , world Only when I put the escape…
sofia.bul
  • 199
  • 1
  • 6
14
votes
1 answer

How to 'cut' on null?

Unix 'file' command has a -0 option to output a null character after a filename. This is supposedly good for using with 'cut'. From man file: -0, --print0 Output a null character ‘\0’ after the end of the filename. Nice to cut(1)…
philcolbourn
  • 3,670
  • 3
  • 26
  • 31
12
votes
2 answers

How can I write to the NUL device under Windows from node.js?

This is bugging me for several days now. I know about the standard stream redirection to the NUL device, but this isn't the case. node.js uses CreateFileW under its fs native/libuv bindings. Unfortunately using something…
SaltwaterC
  • 272
  • 3
  • 11
11
votes
2 answers

Python - how to read file with NUL delimited lines?

I usually use the following Python code to read lines from a file : f = open('./my.csv', 'r') for line in f: print line But how about if the file is line delimited by "\0" (not "\n") ? Is there a Python module that could handle this ? Thanks…
user1129812
  • 2,569
  • 7
  • 28
  • 44
11
votes
4 answers

Could sed or awk use NUL character as record separator?

I have a NUL delimited output coming from the following command : some commands | grep -i -c -w -Z 'some regex' The output consists of records of the format : [file name]\0[pattern count]\0 I want to use text manipulation tools, such as sed/awk,…
user1129812
  • 2,569
  • 7
  • 28
  • 44
11
votes
4 answers

How should character arrays be used as strings?

I understand that strings in C are just character arrays. So I tried the following code, but it gives strange results, such as garbage output or program crashes: #include int main (void) { char str [5] = "hello"; puts(str); } Why…
Lundin
  • 155,020
  • 33
  • 213
  • 341
10
votes
1 answer

Python bug: null byte in input prompt

I've found that input('some\x00 text') will prompt for some instead of some text. From sources, I've figured out that this function uses C function PyOS_Readline, which ignores everything in prompt after NULL byte. From PyOS_StdioReadline(FILE…
6
votes
4 answers

In C, is the condition : "if(a != NULL)" the same as the condition "if(a)"?

Let's say a is a pointer, and after allocating memory for it, I want to check if the memory was allocated successfully, I've seen two ways doing this : if(a != NULL) if(a) What is the difference between the first and second statements ?
6
votes
2 answers

How to handle empty rows in CROSS APPLY [SQL Server]

I've below Stored Procedure- ALTER PROCEDURE [dbo].[Optimized_GetArticlePostAMP] ( @PostID int …
user5426326
6
votes
1 answer

Null byte stops for `print` but not `strlen`, why?

I was playing around with Dart strings and noticed this: print("\x00nullbyte".length); print("\x00nullbyte"); If you run this, you'll find that the length is 9, which includes the null byte. But there is no output. Trusting Google engineers more…
conradkleinespel
  • 5,357
  • 7
  • 39
  • 74
1
2 3
11 12