Cursed Knowledge

Cider99861 pts0 comments

Cursed Knowledge | Obscura

Manage AccountGet Started

Oct 22, 2025<br>btoa() in JavaScript is cursed<br>JavaScript’s btoa doesn’t support multi-byte characters as input. The workaround is to manually encode into UTF-8 then base64 encode with btoa by hacking the bytes into a string. TL;DR - the “b” in “binary to ascii” is greatly exaggerated.

btoa("💩") // Uncaught DOMException: String contains an invalid character

// Workaround: encode to UTF-8 first

const encoder = new TextEncoder();

encoder.encode("💩").toBase64();

Oct 21, 2025<br>MySQL is cursed

Many SQL statements silently trigger an implicit commit in MySQL

Single-table UPDATE assignments are generally evaluated from left to right. So UPDATE t SET a = 1, b = a will probably set b to 1, but you’re relying on undocumented behavior.

For a multi-table UPDATE, there is no guarantee that assignments are carried out in any particular order. If you reference a column that’s also being updated, the result is undefined.

Oct 9, 2025<br>iOS network extensions are cursed<br>On iOS, any app with any of the VPN entitlements, such as com.apple.developer.networking.vpn.api and com.apple.developer.networking.networkextension, can turn off VPN tunnels by enabling its own VPN configuration.

Oct 8, 2025<br>DateFormatter strings are cursed<br>When using Swift’s DateFormatter, if a locale is not set on the DateFormatter, the user’s locale settings will override the date format. This means that the user’s 24-hour time preference can change how format strings like hh behave.

// When 24-hour time is set in user settings on Apple platforms

// (Settings > General > Date & Time > 24 Hour Time)

// 13:43 in afternoon ET, for demonstration

let exampleDateAfternoon = Date(timeIntervalSince1970: 1770230613)

let dateFormatter = DateFormatter()

dateFormatter.timeZone = TimeZone(abbreviation: "EST") // so this example is reproducible

// With this dateFormat, we expect to print:

// 2026-02-04 01:43:33 PM -0500

dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss a Z"

print(dateFormatter.string(from: exampleDateAfternoon))

// Unexpected: user's preference overrides "hh" - prints (note that 13 PM is wrong):

// 2026-02-04 13:43:33 PM -0500

dateFormatter.locale = Locale(identifier: "en_US_POSIX")

print(dateFormatter.string(from: exampleDateAfternoon))

// Fix: Explicitly setting a locale restores the expected behaviour - prints:

// 2026-02-04 01:43:33 PM -0500

let utcDateFormat: ISO8601DateFormatter = ISO8601DateFormatter()

print(utcDateFormat.string(from: exampleDateAfternoon))

// Alternative: Only use if you are okay with the ISO-8601 format - prints:

// 2026-02-04T18:43:33Z

General > Date & Time > 24 Hour Time)// 13:43 in afternoon ET, for demonstrationlet exampleDateAfternoon = Date(timeIntervalSince1970: 1770230613)let dateFormatter = DateFormatter()dateFormatter.timeZone = TimeZone(abbreviation: "EST") // so this example is reproducible// With this dateFormat, we expect to print:// 2026-02-04 01:43:33 PM -0500dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss a Z"print(dateFormatter.string(from: exampleDateAfternoon))// Unexpected: user's preference overrides "hh" - prints (note that 13 PM is wrong):// 2026-02-04 13:43:33 PM -0500dateFormatter.locale = Locale(identifier: "en_US_POSIX")print(dateFormatter.string(from: exampleDateAfternoon))// Fix: Explicitly setting a locale restores the expected behaviour - prints:// 2026-02-04 01:43:33 PM -0500let utcDateFormat: ISO8601DateFormatter = ISO8601DateFormatter()print(utcDateFormat.string(from: exampleDateAfternoon))// Alternative: Only use if you are okay with the ISO-8601 format - prints:// 2026-02-04T18:43:33Z">

dateformatter string locale exampledateafternoon print from

Related Articles