Web Technology Basics

To put the Japanese character "あ" into a URL query, the byte sequence representing it in UTF-8 (E3 81 82) is percent-encoded. Which of the following is the correct result?

  1. A%E3%81%82
  2. B%u3042
  3. Cあ
Show answer and explanation

Answer: A. %E3%81%82

In percent-encoding, when characters that cannot be written in a URL as they are, or characters with special meanings such as / ? # &, are used as data, the characters are turned into bytes and each byte is written as "%" followed by two hexadecimal digits. "あ" is the three bytes E3 81 82 in UTF-8, so it becomes %E3%81%82. A space becomes %20 (in the form submission format, + is also used). In JavaScript, the encodeURIComponent function performs this conversion.

  • A. Correct. Each of the three bytes is written in the form %XX.
  • B. This notation uses the Unicode code point (U+3042) and is what JavaScript's old escape function outputs, but it is not a standard notation for URLs.
  • C. This is a character reference, the HTML notation for writing a character by its number; it is not URL percent-encoding.
Practice this topic Back to topic

Books on Web Technology Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Web Technology Basics questions

  1. A chat app needs to deliver new messages from the server to the browser immediately. Which of the following correctly describes WebSocket?
  2. A merchant's server wants to know immediately when a payment is completed on an online payment service. Which of the following correctly describes the method in which the payment service sends a notification by HTTP POST to a URL the merchant registered in advance (a webhook)?
  3. Which of the following correctly describes the DOM (Document Object Model) used in browsers?
  4. For the element styled with the CSS above, which of the following is the width from the outer edge of the left border to the outer edge of the right border?
  5. Assume there are no other style specifications. In the HTML above, which of the following is the color of the text "Hello"?