Why can’t I static_cast between char * and unsigned char *?

They are completely different types see standard: 3.9.1 Fundamental types [basic.fundamental] 1 Objects declared as characters char) shall be large enough to store any member of the implementation’s basic character set. If a character from this set is stored in a character object, the integral value of that character object is equal to the value … Read more

Efficiently repeat a character/string n times in Scala

For strings you can just write “abc” * 3, which works via StringOps and uses a StringBuffer behind the scenes. For characters I think your solution is pretty reasonable, although char.toString * n is arguably clearer. Do you have any reason to suspect the List.fill version isn’t efficient enough for your needs? You could write … Read more

assigning more than one character in char

It’s a multi-character literal. An ordinary character literal that contains more than one c-char is a multicharacter literal . A multicharacter literal has type int and implementation-defined value. Also from 6.4.4.4/10 in C11 specs An integer character constant has type int. The value of an integer character constant containing a single character that maps to … Read more

Incrementing Char Type In Java

In Java, char is a numeric type. When you add 1 to a char, you get to the next unicode code point. In case of ‘A’, the next code point is ‘B’: char x=’A’; x+=1; System.out.println(x); Note that you cannot use x=x+1 because it causes an implicit narrowing conversion. You need to use either x++ … Read more