Here is an exploration of some methods demonstrating different ways to work with encodings, bytes, numbers, and type conversions in Ruby:

irb(main):003:0> require 'base64'
=> true
irb(main):004:0> Base64.encode64("a")
=> "YQ==\n"
irb(main):005:0> Base64.decode64("YQ==\n")
=> "a"
irb(main):006:0> "0x0a".hex
=> 10
irb(main):007:0> 97.chr
=> "a"
irb(main):008:0> "a".ord
=> 97
irb(main):009:0> "a".bytes
=> [97]
irb(main):010:0> "YQ==".unpack('m')
=> ["a"]
irb(main):011:0> "\xC3".force_encoding('iso-8859-1').encode('utf-8')
=> "Ã"
irb(main):013:0> puts "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9".unpack("m*")
{"typ":"JWT","alg":"HS256"}
=> nil
irb(main):014:0> puts Base64.decode64("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9")
{"typ":"JWT","alg":"HS256"}
=> nil
irb(main):015:0> hi = "hello".bytes
irb(main):035:0> hi
=> [104, 101, 108, 108, 111]
irb(main):016:0> hi.pack("c*")
=> "hello"
irb(main):017:0> 11.to_s(2)
=> "1011"
irb(main):018:0> 13.to_s(2)
=> "1101"
irb(main):021:0> "1101".to_i(2)
=> 13
irb(main):022:0> 0xfa
=> 250
irb(main):023:0> 0b11
=> 3
irb(main):024:0> ".".ord.to_s(16)
=> "2e"
irb(main):025:0> "9gG\xC0E\xD9\x91!".unpack('Q>') # 64-bit network (big-endian) order, 'Q' native (little-endian) order
=> [4136353673894269217]
irb(main):026:0> # Intel processors little-endian integers, example:
irb(main):027:0> "\x00\x01".unpack('S')
=> [256]
irb(main):028:0> "\x01\x00".unpack('n')
=> [256]
irb(main):029:0> 8.times { |x| p 16**(x+1)} # powers of 16, hex places: 16, 256, 4096, 65536, 1048576
16
256
4096
65536
1048576
16777216
268435456
4294967296
=> 8
irb(main):030:0> puts "\u9999".encode('utf-8')=> nil
irb(main):031:0> # The reserved connection location is reserved for the super user:
irb(main):032:0> puts "\xd2ѱ\xa3\xc1\xf4\xb5\xc4\xc1\xac\xbd\xd3λ\xd6\xc3Ϊִ\xd0зǸ\xb4\xd6\xc6\xc7\xeb\xc7\xf3\xb5ij\xac\xbc\xb6\xd3û\xa7Ԥ\xc1\xf4".force_encoding('gb2312').encode('
utf-8')
已保留的连接位置为执行非复制请求的超级用户预留
=> nil
irb(main):023:0> "\x45\x6e\x64"
=> "End"