Menu
  • HOME
  • TAGS

Unicode characters in /bin/sh VS /bin/bash

bash,unicode,sh,chars

If you want to print a unicode character in /bin/sh (which isn't required by POSIX to support \u sequences), either embed it literally in your script or break it down into its component bytes and print those individually. For the snowflake symbol used in the question: printf '\342\235\204' Now, how...

Trying to compare chars from matrix C

c,matrix,chars

In count_points, you try to compare three values with expressions like if (a == b == c) ... This doesn't do what you think it does. You treat it like a comparison in mathematical notation, but C interprets it as: if ((a == b) == c) ... The comparison a...

C programming language :if statements are not working correctly with characters [duplicate]

c,if-statement,chars

This should work for you: #include <stdio.h> #include <string.h> //^^^^^^^^ Don't forget to include this library for the 2 functions int main() { char history[200]; strcpy(history, "NY school"); //^^^^^^^Copies the string into the variable if(strcmp(history, "NY school") == 0) { //^^^^^^ Checks that they aren't different printf("good"); } else {...

Reading text file and breaking it by delimiters

c,arrays,chars

Having read a line as you are doing, you need to split it into item entries. Since you're using strtok(), I assume that you don't need to identify the delimiter. Also, one of the reasons for disliking strtok() and preferring strtok_s() on Windows and strtok_r() everywhere else is that you...

Turn NumPy Array of characters into a string

python,arrays,numpy,chars

You can use tostring() method of numpy as: >>> st = np.array(['K' 'R' 'K' 'P' 'T' 'T' 'K' 'T' 'K' 'R' 'G' 'L']) >>> st.tostring() 'KRKPTTKTKRGL' Since you have a numpy array, this method will be faster than join(). For Python3x tostring() can be used as: >>> st = np.array(['K','R','K','P','T','T','K','T','K','R','G','L'])...

Character digit not true when read from UTF-8 file

java,utf-8,filestream,chars

As finally found by exchanging comments, your file includes a BOM. This is generally not recommended for UTF-8 files because Java does not expect it and sees it as data. So there are two options you have: if you are in control of the file, reproduce it without the BOM...

Storing two separate values from an array into a single array index in C++

c++,arrays,chars

Please provide code which is correctly formed, you have an error on this line: char buffer[length]; You lenght must be const. You can solve this by reading each nomber and convert it to int. But no way to store 33 at once....

Python: Insert two sets of chars into a matrix

python,matrix,fill,chars

You can just concatenate the strings and then just iterate it in order. Then use the floor operation // and the modulus operator % to get the correct indices into the matrix. >>> keyword = 'keyword' >>> alphabet = 'abcfghjlmnpqstuvxz' >>> >>> # Make an empty matrix -- could also...

C++ 'std::out_of_range' error when turning string into character array

c++,arrays,chars

The reason is that L is the length of the array and you do this: c = L; because of 0 indexing you are starting past the end of the string. Try this: c = L-1; Of course since this is c++, I am going to tell you the standard...

Trying to pass a string as an argument for a class but it is being recognized as an array of chars instead in C++

c++,arrays,string,constructor,chars

The problem is not the string. The const char[7] would be successfully used to construct the temporary std::strings. The problem is you are trying to bind int literals to references-to-non-const; you cannot do that. Accepting const int& into your constructor would fix your program. However, I recommend changing your constructor...