Questions tagged [isspace]

Use the isspace tag for languages which provide a function or macro with that name to decide whether characters are white space, such as C or C++.

Some languages provide an isspace function or macro to enable programs to establish whether a specific character is white space or not.

Questions about this facility should use this tag.

26 questions
8
votes
6 answers

Why do a bitwise-and of a character with 0xff?

I am reading some code that implements a simple parser. A function named scan breaks up a line into tokens. scan has a static variable bp that is assigned the line to be tokenized. Following the assignment, the whitespace is skipped over. See below.…
Roger Costello
  • 3,007
  • 1
  • 22
  • 43
3
votes
2 answers

How to fix argument of type is incompatible with parameter of type

I used the function isspace to search through a word for white spaces. The problem is that I get an error message when the program builds: "argument of type char* is incompatible with parameter of type int" int const bufferSize = 256; …
Breaks Coder
  • 53
  • 3
  • 7
2
votes
2 answers

Can isspace() give false positives with UTF-8 text?

I know isspace() is meant to work for ASCII, but I have UTF-8 text. If isspace() looks only at the lower 7 bits, where UTF-8 and ASCII overlaps, it should be safe to use. By safe to use I mean that it won't detect a Unicode character that is not a…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
1
vote
1 answer

Why is isspace() returning false for strings from the docx python library that are empty?

My objective is to extract strings from numbered/bulleted lists in multiple Microsoft Word documents, then to organize those strings into a single, one-line string where each string is ordered in the following manner: 1.string1 2.string2 3.string3…
1
vote
1 answer

Debug assertion failed, Expression: (unsigned)(c + 1) <=256 Ask Question c++

I want to count the number of spaces. As I understand it, compiler sweare at this line isspace(s[step]) != 0. But sometimes the code started and there was no error. I don't know why it is so. char s[] = "So she was considering"; int number_space =…
A.Kross
  • 165
  • 8
1
vote
4 answers

Python isspace function

I'm having difficulty with the isspace function. Any idea why my code is wrong and how to fix it? Here is the problem: Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the…
jr17420975320
  • 13
  • 1
  • 4
1
vote
1 answer

Debug assertion failed with std::erase

I'm writing a program to parse a logfile, and decided to be as C++ about that as possible and I got hit with debug assertion for this line - sLine.erase(remove_if(sLine.begin(), sLine.end(), isspace), sLine.end()); Which seems to because of a…
1
vote
3 answers

Check whether a string is empty (or spaces)

I have a string which is : >>> a = "   " >>> a.isspace() False >>> a '\xe2\x80\x83\xe2\x80\x83 \xe2\x80\x83\xe2\x80\x83 \xe2\x80\x83\xe2\x80\x83 \xe2\x80\x83\xe2\x80\x83 …
Excalibur
  • 431
  • 6
  • 19
1
vote
4 answers

if(isspace()) statement not working C++

I am working on a function for my program that reads the first and last name from a text file and saves them as two strings. However, I cannot get the if(isspace(next)) statement to execute when the for-loop reaches the first space in between the…
Keudn
  • 11
  • 3
1
vote
1 answer

Counting words from input file adding extra word?

I am trying to count uppercase and lowercase letters, the number of digits, and the number of words in an input file. I have completed this, however, my word count is off by one. There are 52 words in the input file, but my count is 53. What would…
ryanpback
  • 275
  • 4
  • 17
1
vote
3 answers

isspace() only works for digits up to 8?

In my code : cout << "Isspace 5 and 10 are " << isspace(5) << " and " << isspace(10) << endl; gives 0 and 8. Why does isspace(10) not give 0 since 10 is not a white space?
Haris Irshad
  • 191
  • 1
  • 4
  • 12
0
votes
2 answers

Nested switch() - case issue in C. Why are functions not working the way I would like them to?

I have been trying to understand why this is not working properly for the past five hours. The question explicitly asks for the use of switch() and no if-else (or of the likes) to count the number of words, lines, and characters in typed up text.…
Marcus G.
  • 3
  • 2
0
votes
0 answers

Check if the strings inside a list of tuples contain whitespace and remove the tuple if true

I have a list of tuples: [('a', 'a', 'a'), ('b', 'b', 'b), ('c',' \n \n \n ', 'c'), ('d', 'd', 'd'),('e', ' \n \n \n ', 'e'] I want to delete the tuples that contain whitespace. My code is: for tuple in list: for string in…
0
votes
0 answers

Is std::isspace the opposite of std::isgraph in C++ (locale versions)

Is std::isspace the opposite of std::isgraph in C++ (locale versions)? That is, is the following true? char c = getCharFromSomewhere(); std::locale loc = getLocaleFromSomewhere(); std::isspace(c, loc) != std::isgraph(c, loc) They seem to be true…
Jimmy
  • 158
  • 1
  • 10
0
votes
0 answers

Determining if its a Whitespace character by user input

I am given a task to write a code that check whether the user input is a white-space character or not. If the input character is a white-space: Print "white-space character" If the input character is not a white-space: Print "not a white-space…
Ryn A
  • 1
1
2