I wonder if <iostream>'s function "endl" has a different encoding across different OS or different compilers.
Yes, it does. Sort of. In reality the conversion is done at level lower than that function.
If you just look at the output, std::endl and '\n' are synonyms.