SShortSingh.
Back to feed

How Social Networks Really Count Characters — and Why .length Gets It Wrong

0
·1 views

A developer building a publishing API across 13 social networks found that character limits are measured differently depending on the platform, making JavaScript's native .length unreliable. Most major platforms including Facebook, Instagram, X, and LinkedIn measure UTF-16 code units, which happens to match .length — but Threads and Bluesky are notable exceptions. Bluesky enforces two simultaneous limits — 300 graphemes and 3,000 bytes — and a post must satisfy both, meaning emoji-heavy or non-Latin text can fail even when a simple character count looks safe. TikTok adds another wrinkle: its app permits up to 4,000 characters, but its Content Posting API rejects posts beyond 2,200, illustrating that the UI limit and the API limit can differ entirely. The key takeaway is that developers must identify the exact unit each API enforces and validate against that specifically, rather than relying on a single length check.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Von der Leyen Warns Frontier AI Could Enable Unprecedented Cyberattacks

European Commission President Ursula von der Leyen used her 2026 State of the Union address to highlight the cybersecurity dangers posed by advanced AI models, warning they could enable hacking at a scale previously unimaginable. She cautioned that such powerful models could fall into the hands of hostile actors, signaling that AI safety, model security, and supplier accountability will remain central to EU policy. Her remarks did not introduce new legal requirements but reinforced the EU's existing governance direction, including the AI Act framework. The EU is also expected to release a dedicated AI cybersecurity plan in July 2026, addressing both the threats and defensive opportunities that advanced AI presents. Von der Leyen additionally called for international cooperation on model evaluation and early warning systems, with partners including Canada and the UK.

0
ProgrammingDEV Community ·

Build a Free Client Portal Using Google Sheets and Sheetrocket in 30 Minutes

Agencies and freelancers often struggle with scattered email threads and disorganized project updates, making it hard for clients to track progress. A tutorial published on DEV Community outlines how to build a structured client portal using Google Sheets and a free tool called Sheetrocket, requiring no coding or database setup. The portal includes a dashboard, milestone tracker, invoice history, document links, and a messaging form, all accessible to clients via a single private link. Sheetrocket offers ready-made templates for various business types, including agency, freelancer, and coaching portals, which can be connected to a copied Google Sheet template. The entire setup is estimated to take around 30 minutes, with the business owner retaining full control over the data through their own Google account.

0
ProgrammingDEV Community ·

Developer replaces free hit counter API with Firebase after mobile blocking issues

A developer building a static web app called Daily Doodle attempted to add a simple visitor hit counter using a free third-party API, countapi.mileshilliard.com. The counter worked correctly on desktop browsers but consistently failed to update on mobile devices, with no visible error shown to users. Investigation revealed the likely cause was the API's domain being blocked at the network level by ad blockers or mobile carrier filters. Switching to Firebase Realtime Database resolved the issue, as Google's infrastructure domain is rarely blocked by such filters. The developer shared a step-by-step setup using Firebase's REST API with server-side atomic increments, requiring no SDK or authentication under the free Spark plan.

0
ProgrammingDEV Community ·

How One Dev Built a Cheat-Resistant Browser Game Leaderboard with Cloudflare D1

A developer built a browser game called 195-0 Game using Astro, Preact, and Cloudflare Workers, where players draft five people for cabinet roles and run a fictional campaign against 195 nations. A key engineering challenge was making the public leaderboard trustworthy without relying solely on client-reported scores. The solution uses signed draft tokens and server-side move replay: the server reconstructs the game from a seed and action log, then issues a signed result token before any leaderboard submission is accepted. Most content pages are prerendered, keeping the site fast, while the server handles draft issuance, score verification, and shareable PNG result card generation. The developer acknowledges the system validates legal move sequences but cannot confirm human participation, meaning a bot could still submit high scores through valid gameplay paths.

How Social Networks Really Count Characters — and Why .length Gets It Wrong · ShortSingh