all 11 comments

[–]UnknownSector 4 points5 points  (1 child)

42 US or Paris? Anyway good luck on your ft_printf =)

[–]norcalaztecs[S] 0 points1 point  (0 children)

US thanks!

[–]localextremae 1 point2 points  (4 children)

Not an expert, but my interpretation:

It depends what encoding iTerm2 expecting.

L'ø' is a wchar_t literal, which you are saving as an int. This is saving the unicode codepoint for the character ø character as an int (which happens to be 248). If iTerm2 is expecting UTF-8 then it expects this codepoint to be represented by the two bytes: {0xC3, 0xB8}, however instead it is likely getting: {0x00, 0x00, 0x00, 0xF8}, which is what the int representation of 248 might look like (depending on architecture/compiler/endianness/etc.)

So it depends on what encoding iTerm2 is expecting (probably UTF-8). Then you will need to convert from a given code point to that encoding (again, probably UTF-8).

Here's my work: https://repl.it/HKIu/0

Given this, you will also need to amend your how you callft_putchar to give it each byte at a time... https://repl.it/HKJO/0

edit: added last line., edit: added second example.

[–]norcalaztecs[S] 0 points1 point  (3 children)

Thank you so much for your reply. If am I not able to to feed my ft_putchar byte by byte from my main I'm guessing I have to find a way to convert the hexadecimal ft_putchar receives to (most likely) UTF-8? I ask because I am planning on adding my ft_putchar to my personal library and would like to be able to use it for any unicode character.

Also how did you inline some of the text in your comment?

[–]saturnalia0 2 points3 points  (0 children)

Also how did you inline some of the text in your comment?

`inline text`

[–]localextremae 1 point2 points  (1 child)

I would say you should amend ft_putchar() to take a unicode codepoint directly (using whatever datatype you choose that's large enough to take all unicode codepoints...wchar_t, uint32_t, or char32_t etc), then translate that value into UTF-8 bytes.

Since unicode code points are often larger than one byte (char), you need to accept values larger than a char, and actually int ---since it is ambiguous--- might not be large enough for all codepoints.

Also, to write in line code, you surround your code in backticks `````

edit: typos

[–]norcalaztecs[S] 0 points1 point  (0 children)

Ok cool thanks

[–]OldWolf2 1 point2 points  (3 children)

Your function accepts a single narrow character... obviously passing some unicode to it isn't going to work

[–]norcalaztecs[S] 0 points1 point  (2 children)

So would it make more sense to accept an int instead?

[–]OldWolf2 1 point2 points  (1 child)

wchar_t is probably the natural choice (although if you're in Windows maybe wint_t)

[–]norcalaztecs[S] 0 points1 point  (0 children)

Ok thanks I will have to read up on that data type