CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • Encoding: why “mojibake” appears

    Kotlin SELF
    Level 44, Lesson 0
    We break down why a “text file” is actually bytes ( ByteArray), how those bytes become strings ( String) via a decoding rule ( Charset), and why mismatched encodings produce “Привет” and “??????”. Using Kotlin/JVM examples, we learn to explicitly encode/decode via Charsets . UTF_8 and diagnose the problem by printing bytes in hex.
    Available
  • Encodings: UTF‑8 / UTF‑16 / ASCII

    Kotlin SELF
    Level 44, Lesson 1
    We break down how encodings turn text into bytes and back: what limits ASCII, why UTF‑8 became the de facto standard (ASCII compatibility and variable length), how UTF‑16 relates to the JVM (the Char type, String.length surprises with emoji), where the “extra bytes” in Charsets.UTF_16 come from, and what typical mistakes lead to “mojibake”.
    Available
  • Stabilizing program behavior

    Kotlin SELF
    Level 44, Lesson 2
    We break down why the “default encoding” is a hidden dependency on the environment, and how to make I/O behavior reproducible: use an explicit Charset and Charsets . UTF_8, read and write text via readText/ writeText, work with ByteArray and manual decoding when needed, apply a streaming approach with bufferedReader/ use, and also build a mini-API so the encoding remains a “single source of truth.” At the end: common mistakes when working with encodings.
    Available
  • BOM — how to recognize it and why it breaks a file

    Kotlin SELF
    Level 44, Lesson 3
    We break down what BOM ( Byte Order Mark) is, why an invisible prefix at the beginning of a file leads to “magic” string mismatches (for example, == suddenly returns false), how to diagnose the problem by bytes ( ByteArray, signature EF BB BF), and how to safely remove BOM at the byte and string levels (via '\uFEFF') without damaging valid data.
    Available
  • Cleaning “dirty text”

    Kotlin SELF
    Level 44, Lesson 4
    We break down how to bring text from a file into a predictable form before parsing: read data as ByteArray, remove the UTF‑8 BOM by its signature EF BB BF, decode via Charsets.UTF_8, normalize line breaks ( "\r\n", "\n", "\r"), and assemble everything into a readCleanUtf8() function so the parser works only with “clean” input.
    Available
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym