様々な方法で \n
の16進表現を調べてみます。
例えば、 \n
の16進表現は a
(0xa
や
0x0a
という表記もあり)です。
方法1 Googleで"man ascii"
方法2 LinuxやMacのターミナルで
$ man ascii
※ 表記の違いに注意
- Linux系の場合
\n
はLF
- Macの場合、
\n
はnl
方法3 Node.jsのREPLで
$ node
> console.log('\n'.charCodeAt(0).toString(16));
a
方法4 Rubyのワンライナーで
$ ruby -e 'p "\n".ord.to_s(16)'
"a"
方法5 Pythonのワンライナーで
$ python -c "print(hex(ord('\n')))"
0xa
方法6 Cで
cr.c
# include <stdio.h>
int main(void)
{
printf("%x\n", '\n');
return 0;
}
方法7 C++で
cr.cpp
# include <iostream>
int main()
{
std::cout << std::hex << static_cast<int>('\n') << std::endl;
return 0;
}