Lab 2.1: The Mojibake Rescue
Act as a localization engineer diagnosing and repairing a multi-lingual string file that suffered Mojibake (character encoding corruption).
Objective
In this hands-on lab, you will act as a localization engineer diagnosing and repairing a multi-lingual string file that suffered Mojibake (character encoding corruption). You will inspect encoding profiles in Visual Studio Code, re-open mis-interpreted files under their original regional encoding, and re-save them cleanly as universal UTF-8.
Required Setup & Prerequisites
Editor: Visual Studio Code installed.
Working Directory: Open your
loc_labworking directory in VS Code.
Step-by-Step Instructions
Step 1: Create the "Corrupted" Mojibake Asset
When a file written in a legacy regional encoding (like Windows-1252 or ISO-8859-2) is opened by a system expecting UTF-8, special characters and foreign alphabets scramble into garbage text. Let's create the corrupted asset you will rescue.
Open VS Code.
Inside
assets/loc/software/, create a new file namedui_mojibake_sample.json.Copy and paste the following broken code snippet into the file:
JSON
json{ "city_name": "Zamoœæ", "welcome_title": "Witaj w naszym mieœcie!", "btn_confirm": "PotwierdŸ" }
What happened here? The original Polish text (Zamość, Witaj w naszym mieście!, Potwierdź) was saved using a Central European encoding profile, but VS Code is trying to read the bytes as standard
UTF-8orWindows-1252, causingśandźto turn intoœ,æ, andŸ.
Save the file (
Cmd + Son macOS /Ctrl + Son Windows).
Step 2: Inspecting Encoding Metadata in VS Code
Look at the Status Bar at the bottom right of the VS Code window.
Observe the encoding profile indicator (it likely says
UTF-8).Notice that while VS Code treats the file as
UTF-8, the actual visible letters inside the string values remain scrambled.
Step 3: Re-Open the File with the Correct Legacy Encoding
To fix Mojibake, you must tell VS Code to re-interpret the raw bytes using the file's original character map.
Click on the
UTF-8indicator in the bottom-right Status Bar (or pressCmd + Shift + P/Ctrl + Shift + Pand typeChange File Encoding).Select Reopen with Encoding.
In the search box that appears, type
ISO-8859-2(orCentral European (ISO 8859-2)).Select
ISO-8859-2and pressEnter.Observe the editor view instantly update:
JSON
json{ "city_name": "Zamość", "welcome_title": "Witaj w naszym mieście!", "btn_confirm": "Potwierdź" }The Polish diacritics (
ś,ć,ź) are fully restored!
Step 4: Convert and Save Permanently as Universal UTF-8
Re-opening the file under ISO-8859-2 fixes the view locally, but modern build pipelines expect UTF-8. You must now convert the underlying file bytes to UTF-8.
Click the encoding indicator in the Status Bar (which now reads
ISO 8859-2).Select Save with Encoding.
Type
UTF-8into the search box and pressEnter.Save the file (
Cmd + S/Ctrl + S).Verify that the Status Bar now explicitly displays
UTF-8and that all Polish characters (ś,ć,ź) remain perfectly rendered on screen.
Step 5: Rename to Clean Production File
Right-click
ui_mojibake_sample.jsonin the Explorer panel Rename (or pressF2).Rename the file to
ui_pl_clean.json.Confirm that the relative path is
assets/loc/software/ui_pl_clean.jsonand the status bar readsUTF-8.
Self-Verification Checklist
Before moving forward, check your cleaned file against these parameters:
[ ] Character corruption (
Zamoœæ) is resolved and correctly rendersZamość.[ ] Status bar explicitly reads
UTF-8.[ ] File contains valid JSON syntax with no red squiggly underlines.
[ ] Asset is saved as
ui_pl_clean.json.
Ready to move on?
Mark this lesson complete when you’re ready.