I'm using ISO 8859-1 (Latin extended ASCII char set) in my C application. When I strcpy
/strcat
the portions of the string together, it works fine. But when I use sprintf("%s %s")
, on some runtimes (particularly certain versions of Android), the string will truncate when an extended ASCII character (specifically é
, although I haven't tried others) is hit.
I thought %s
was just supposed to copy the bytes until '\0'
was hit. I suspect that strcpy
/strcat
works because it does do just that, without any formatting. What could possibly be going on here?
I should note that I'm not viewing the text using printf()
, rather my own text rendering engine which handles ISO-8859-1 just fine.
UPDATE: To clarify, I have an NDK app, which is keeping the string in C, and passing it to my OpenGL based text rendering engine. If I pass the full string as a char* literal, it displays fine. If I sprintf() the portions together, it gets truncated at the é character. For example:
char buffer[1024];
strcpy(buffer, "This is ");
strcat(buffer, "the string I want to diésplay.");
That shows up fine. But this:
sprintf(buffer, "%s%s", "This is ", "the string I want to diésplay.");
Prints as:
This is the string I want to di