短语在不同编码中有多少字节

时间:2014-05-11 13:52:47

标签: encoding utf-8 utf-16 iso-8859-1 utf-32

任务是 - 考虑西班牙语短语

 "¡Aquí!"

ISO-8859-1编码中有多少字节? UTF-8有多少? UTF-16有多少? UTF-32有多少?

我的解决方案是

- ISO 8859-1 = 6 bytes
- UTF-8 =8 bytes
- UTF-16 = 12 bytes
- UTF-32 = 24 bytes

是吗?

- ISO 8859-1 = 6 (6*1) (ISO 8859-1 is a single-byte encoding)

- UTF – 8 = 2+1+1+1+2+1=8 (1byte for ASCII character: A, q, u, ! are ASCII 
  characters    (0 till 127), ¡ and í are 2 bytes each, their values are 161 
  and 237 correspondingly).

- UTF16 = 12 (6*2) (2 bytes for 0-FFFF (65535)

- UTF32 = 24 (6*4) (4 bytes for everything)

1 个答案:

答案 0 :(得分:0)

  
      
  • ISO 8859-1 = 6字节
  •   
  • UTF-8 = 8字节
  •   
  • UTF-16 = 12字节
  •   
  • UTF-32 = 24字节
  •   
     

是吗?

(你没有考虑过UTF-16和UTF-32的字节顺序标记,它会分别增加两个和四个字节,但对于作业问题来说这是一个可接受的答案。)