Character encoding Ocaml字符
在ruby中,我可以执行以下操作:Character encoding Ocaml字符,character-encoding,char,ocaml,Character Encoding,Char,Ocaml,在ruby中,我可以执行以下操作: printf("%c ", 0x6A) # ┘ printf("%c ", 0x6B) # ┐ printf("%c ", 0x6C) # ┌ printf("%c ", 0x6D) # └ printf("%c ", 0x6E) # ┼ printf("%c ", 0x71) # ─ printf("%c ", 0x74) # ├ printf("%c ", 0x75) # ┤ printf("%c ", 0x76) # ┴ 如何使用ocaml打印这些字
printf("%c ", 0x6A) # ┘
printf("%c ", 0x6B) # ┐
printf("%c ", 0x6C) # ┌
printf("%c ", 0x6D) # └
printf("%c ", 0x6E) # ┼
printf("%c ", 0x71) # ─
printf("%c ", 0x74) # ├
printf("%c ", 0x75) # ┤
printf("%c ", 0x76) # ┴
如何使用ocaml打印这些字符
在Utop中,我得到:
utop # let x = '0x6A';;
Error: Syntax error
从字面上说
open Printf
printf "%c " '\x6A'
您还可以使用char_of_int函数使用ASCII编码将整数代码转换为字符:
printf "%c" (char_of_int 0x6a)
还有Char.chr
如果要将x定义为字符类型:
# let x=char_of_int 0x6A;;
val x : char = 'j'
# Printf.printf "%c" x;;
j- : unit = ()
# let x=char_of_int 0x6A;;
val x : char = 'j'
# Printf.printf "%c" x;;
j- : unit = ()