Cursed Knowledge
Cursed knowledge we obtained as a result of building Obscura that we wish we never learned.
-
btoa() in JavaScript is cursed
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 firstconst encoder = new TextEncoder();toBase64(encoder.encode("💩").buffer) -
MySQL is cursed
-
Many SQL statements silently trigger an implicit commit in MySQL
-
Single-table
UPDATEassignments are evaluated from left to right. SoUPDATE t SET a = 1, b = asets b to 1, whileUPDATE t SET b = a, a = 1sets b to the previous value of a. So referencing a column on the right-hand side of anUPDATEassignment can give different results depending on assignment order.
-
-
iOS network extensions are cursed
On iOS, any app with any of the VPN entitlements, such as
com.apple.developer.networking.vpn.apiandcom.apple.developer.networking.networkextension, can turn off VPN tunnels by enabling its own VPN configuration. -
DateFormatter strings are cursed
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 likehhbehave.// 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 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