jatlylee
jatlylee

Reputation: 13

Equivalent of php's chr in golang

i am try to change a fuction from php to golang . the function job is use chr,ord,base4_encode to encode some string。php generate a serial int number, like 122|234|135|138|179|19|190|183|80|156|4|159|195|213|86|241|140|7|112|23|61|182|37|91|185|26|203|185|206|206|183, some number biger than 127,the ascii bigest number is 127. now, the probrem is: php's chr(206) is not equivalent golang's string(rune(206))

please help me,thx

Upvotes: 0

Views: 729

Answers (1)

Adrian
Adrian

Reputation: 46552

The results in PHP and Go are different because, as the documentation for each states, PHP's chr returns the ASCII character for its argument, whereas Go's rune uses UTF-8. Below 127, ASCII and UTF-8 are the same, but above that, they differ.

Upvotes: 1

Related Questions