Thanks SzG and M Oehm for you comments.
As you said, M Oehm, the linux example is working.
I found the problem in my code. I was using the color value for Windows instead of the ones for Linux.
For example:
_ftprintf(target, TEXT("%c[%d;%dm%s%c[K\n"),
0x1B, foreground, background, printBuffer, 0x1B);
The values for foreground and background were not correct.
Now it's working.