ruby - Anyone knows what's going on with "weird" characters at the beginning of a string? -


i've run strange issue when trying detect string among array of them. knows what's going on here?

(rdb:1) p magic_string "time period" (rdb:1) p magic_string.class string (rdb:1) p magic_string == "time period" false (rdb:1) p "time period".length 11 (rdb:1) p magic_string.length 14 (rdb:1) p magic_string[0].chr "\357" (rdb:1) p magic_string[1].chr "\273" (rdb:1) p magic_string[2].chr "\277" (rdb:1) p magic_string[3].chr "t" 

your string contains 3 bytes (bom) @ beginning indicate encoding utf-8.

q: bom?

a: byte order mark (bom) consists of character code u+feff @ beginning of data stream, can used signature defining byte order , encoding form, of unmarked plaintext files. under higher level protocols, use of bom may mandatory (or prohibited) in unicode data stream defined in protocol.

source


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -