Weird pesky tilted ' and ’

hello,

I am writing a piece of code that replaces caracters in a string and i need some help.
The problem is is that i do not know the code for ’ .. while i do know the code for '
(you have to press your nose to the screen to see the difference, but one of them is 'tilted')

the code i use is as following, and it does work in other parts of my program where i substitute other letters:
1
2
 replace( output5.begin(), output5.end(), '’', '\'' );
out << output5 << "\t";

so if output5 is jsfbsekjf’kafk i want it to become jsfbsekjf'kafk

i tried to substitute the caracter ’ by \u00B4 bit it did not work.

Can anybody help me? i'm just a beginner so please make it micky mouse language.




Assuming the tilted accent is assigned a value of 0xB4, you can just use that as a hex code in the string:

 
replace( output.begin(), output.end(), '\xB4', '\'' );


However, this character may or may not actually be assigned a value of B4 depending on whatever code page your data is using. Try it and see if it works. If it doesn't, you'll have to figure out which value that character is actually representing.
it's a-cute accent lol. Seriously though, that is what it is called acute accent

Run this c code to find out what value it is on your machine:
1
2
3
4
5
6
7
8
9
#include <stdio.h>

int main() {
	unsigned c, eof = -1;
	for (c = getchar(); c != eof; c = getchar()) {
		printf("%c == %u\n", c, c);
	}
	return 0;
}
okey, i know what code i need to use to represent the symbol

replace( output5.begin(), output5.end(), '\342\200\231’', '\'' );

it sais deduced conflicting types for parameters 'const_tp (int and char)

it means my variabels are not in the right form, but i have nu clue. I've tried to change it, but i do not see why i can replace yyy with \' but not why i cannot replace \342\200\231 with something. i mean 3 characters(yyy) versus 3 characters must be the same result right? what is the difference? y u no work code..
'a' is a single character and have a type of char

'abcd' is a multicharacter literal and have a type of int

It is just like your compules tells you: mismatching types
Last edited on
like MiiNiPaa said. '\342\200\231’' is a string of 3 chars you need a single char.

try this page for more info https://www.cl.cam.ac.uk/~mgk25/ucs/apostrophe.html
Topic archived. No new replies allowed.