[{"data":1,"prerenderedAt":809},["ShallowReactive",2],{"guide-sms-character-counting-encoding":3},{"id":4,"title":5,"body":6,"date":801,"description":802,"extension":803,"meta":804,"navigation":279,"path":805,"readingTime":306,"seo":806,"stem":807,"__hash__":808},"guides\u002Fguides\u002Fsms-character-counting-encoding.md","SMS Character Counting and Encoding: Why 160 Is Not Always 160",{"type":7,"value":8,"toc":791},"minimark",[9,13,18,26,37,40,97,104,108,115,121,124,135,139,146,191,194,197,200,539,543,546,640,651,655,709,713,750,754,775,779,787],[10,11,12],"p",{},"The 160-character SMS limit is one of the most misunderstood constraints in tech. In practice, your message might allow only 70 characters — or it might silently split into multiple segments that cost extra. The difference comes down to character encoding.",[14,15,17],"h2",{"id":16},"the-gsm-7-alphabet","The GSM-7 Alphabet",[10,19,20,21,25],{},"The original SMS standard uses the ",[22,23,24],"strong",{},"GSM 7-bit alphabet"," (GSM-7), which encodes 128 characters in 7 bits each. Because SMS messages travel in 140-byte packets, a 7-bit encoding fits:",[27,28,33],"pre",{"className":29,"code":31,"language":32},[30],"language-text","140 bytes × 8 bits\u002Fbyte = 1120 bits\n1120 bits ÷ 7 bits\u002Fchar = 160 characters\n","text",[34,35,31],"code",{"__ignoreMap":36},"",[10,38,39],{},"GSM-7 covers uppercase and lowercase Latin letters, digits, and common punctuation. However, it is not ASCII — some characters differ:",[41,42,43,55,62,73,82],"ul",{},[44,45,46,47,50,51,54],"li",{},"Tilde ",[34,48,49],{},"~"," is not in GSM-7 (use ",[34,52,53],{},"=>"," in escape sequences)",[44,56,57,58,61],{},"Backtick ",[34,59,60],{},"`"," is absent",[44,63,64,65,68,69,72],{},"Curly braces ",[34,66,67],{},"{"," ",[34,70,71],{},"}"," are absent",[44,74,75,76,68,79,72],{},"Square brackets ",[34,77,78],{},"[",[34,80,81],{},"]",[44,83,84,85,88,89,92,93,96],{},"The caret ",[34,86,87],{},"^",", pipe ",[34,90,91],{},"|",", and backslash ",[34,94,95],{},"\\"," require two-character escape sequences",[10,98,99,100,103],{},"When you use any of these escape characters, they consume 14 bits instead of 7 — effectively counting as ",[22,101,102],{},"two characters"," in your SMS length.",[14,105,107],{"id":106},"when-ucs-2-takes-over","When UCS-2 Takes Over",[10,109,110,111,114],{},"If your message contains even a single character outside GSM-7 — an emoji, a Chinese character, a Cyrillic letter — the entire message switches to ",[22,112,113],{},"UCS-2 encoding"," (16 bits per character). UCS-2 uses the same 140-byte packet, but fits fewer characters:",[27,116,119],{"className":117,"code":118,"language":32},[30],"140 bytes × 8 bits\u002Fbyte = 1120 bits\n1120 bits ÷ 16 bits\u002Fchar = 70 characters\n",[34,120,118],{"__ignoreMap":36},[10,122,123],{},"One emoji drops your limit from 160 to 70 characters. This is the most common reason messages split unexpectedly.",[10,125,126,127,130,131,134],{},"Modern SMS gateways use ",[22,128,129],{},"UTF-16"," instead of UCS-2, which handles surrogate pairs for characters outside the Basic Multilingual Plane (emoji like 🎉, 🏳️‍🌈). Characters requiring surrogate pairs consume 32 bits (4 bytes) — counting as ",[22,132,133],{},"two UCS-2 characters"," each.",[14,136,138],{"id":137},"message-segmentation","Message Segmentation",[10,140,141,142,145],{},"When your message exceeds the single-message character limit, it is split into segments. Each segment includes a ",[22,143,144],{},"User Data Header (UDH)"," — 6 bytes of metadata for reassembly — reducing the available space per segment:",[147,148,149,165],"table",{},[150,151,152],"thead",{},[153,154,155,159,162],"tr",{},[156,157,158],"th",{},"Encoding",[156,160,161],{},"Single Message",[156,163,164],{},"Per Segment (concatenated)",[166,167,168,180],"tbody",{},[153,169,170,174,177],{},[171,172,173],"td",{},"GSM-7",[171,175,176],{},"160 chars",[171,178,179],{},"153 chars",[153,181,182,185,188],{},[171,183,184],{},"UCS-2",[171,186,187],{},"70 chars",[171,189,190],{},"67 chars",[10,192,193],{},"A 200-character GSM-7 message splits into two segments: 153 + 47 characters. You pay for two messages.",[10,195,196],{},"A 75-character UCS-2 message also splits into two segments: 67 + 8 characters. You pay for two messages.",[10,198,199],{},"Segment limit calculation:",[27,201,205],{"className":202,"code":203,"language":204,"meta":36,"style":36},"language-javascript shiki shiki-themes github-light github-dark","function calculateSegments(text) {\n  const isGSM7 = \u002F^[\\x00-\\x7F\\u00A0\\u00A3\\u00A5\\u00A7\\u00C0-\\u00FF]*$\u002F.test(text)\n  \u002F\u002F Simplified — real GSM-7 detection requires checking the full alphabet\n\n  if (isGSM7) {\n    const singleLimit = 160\n    const segmentLimit = 153\n    return text.length \u003C= singleLimit ? 1 : Math.ceil(text.length \u002F segmentLimit)\n  } else {\n    const singleLimit = 70\n    const segmentLimit = 67\n    \u002F\u002F Account for surrogate pairs (emoji = 2 UCS-2 chars)\n    const ucs2Length = [...text].reduce((count, char) => {\n      return count + (char.codePointAt(0) > 0xFFFF ? 2 : 1)\n    }, 0)\n    return ucs2Length \u003C= singleLimit ? 1 : Math.ceil(ucs2Length \u002F segmentLimit)\n  }\n}\n","javascript",[34,206,207,230,267,274,281,290,304,317,360,372,384,396,402,443,487,497,527,533],{"__ignoreMap":36},[208,209,212,216,220,224,227],"span",{"class":210,"line":211},"line",1,[208,213,215],{"class":214},"szBVR","function",[208,217,219],{"class":218},"sScJk"," calculateSegments",[208,221,223],{"class":222},"sVt8B","(",[208,225,32],{"class":226},"s4XuR",[208,228,229],{"class":222},") {\n",[208,231,233,236,240,243,247,249,252,255,258,261,264],{"class":210,"line":232},2,[208,234,235],{"class":214},"  const",[208,237,239],{"class":238},"sj4cs"," isGSM7",[208,241,242],{"class":214}," =",[208,244,246],{"class":245},"sZZnC"," \u002F",[208,248,87],{"class":214},[208,250,251],{"class":238},"[\\x00-\\x7F\\u00A0\\u00A3\\u00A5\\u00A7\\u00C0-\\u00FF]",[208,253,254],{"class":214},"*$",[208,256,257],{"class":245},"\u002F",[208,259,260],{"class":222},".",[208,262,263],{"class":218},"test",[208,265,266],{"class":222},"(text)\n",[208,268,270],{"class":210,"line":269},3,[208,271,273],{"class":272},"sJ8bj","  \u002F\u002F Simplified — real GSM-7 detection requires checking the full alphabet\n",[208,275,277],{"class":210,"line":276},4,[208,278,280],{"emptyLinePlaceholder":279},true,"\n",[208,282,284,287],{"class":210,"line":283},5,[208,285,286],{"class":214},"  if",[208,288,289],{"class":222}," (isGSM7) {\n",[208,291,293,296,299,301],{"class":210,"line":292},6,[208,294,295],{"class":214},"    const",[208,297,298],{"class":238}," singleLimit",[208,300,242],{"class":214},[208,302,303],{"class":238}," 160\n",[208,305,307,309,312,314],{"class":210,"line":306},7,[208,308,295],{"class":214},[208,310,311],{"class":238}," segmentLimit",[208,313,242],{"class":214},[208,315,316],{"class":238}," 153\n",[208,318,320,323,326,329,332,335,338,341,344,347,350,353,355,357],{"class":210,"line":319},8,[208,321,322],{"class":214},"    return",[208,324,325],{"class":222}," text.",[208,327,328],{"class":238},"length",[208,330,331],{"class":214}," \u003C=",[208,333,334],{"class":222}," singleLimit ",[208,336,337],{"class":214},"?",[208,339,340],{"class":238}," 1",[208,342,343],{"class":214}," :",[208,345,346],{"class":222}," Math.",[208,348,349],{"class":218},"ceil",[208,351,352],{"class":222},"(text.",[208,354,328],{"class":238},[208,356,246],{"class":214},[208,358,359],{"class":222}," segmentLimit)\n",[208,361,363,366,369],{"class":210,"line":362},9,[208,364,365],{"class":222},"  } ",[208,367,368],{"class":214},"else",[208,370,371],{"class":222}," {\n",[208,373,375,377,379,381],{"class":210,"line":374},10,[208,376,295],{"class":214},[208,378,298],{"class":238},[208,380,242],{"class":214},[208,382,383],{"class":238}," 70\n",[208,385,387,389,391,393],{"class":210,"line":386},11,[208,388,295],{"class":214},[208,390,311],{"class":238},[208,392,242],{"class":214},[208,394,395],{"class":238}," 67\n",[208,397,399],{"class":210,"line":398},12,[208,400,401],{"class":272},"    \u002F\u002F Account for surrogate pairs (emoji = 2 UCS-2 chars)\n",[208,403,405,407,410,412,415,418,421,424,427,430,433,436,439,441],{"class":210,"line":404},13,[208,406,295],{"class":214},[208,408,409],{"class":238}," ucs2Length",[208,411,242],{"class":214},[208,413,414],{"class":222}," [",[208,416,417],{"class":214},"...",[208,419,420],{"class":222},"text].",[208,422,423],{"class":218},"reduce",[208,425,426],{"class":222},"((",[208,428,429],{"class":226},"count",[208,431,432],{"class":222},", ",[208,434,435],{"class":226},"char",[208,437,438],{"class":222},") ",[208,440,53],{"class":214},[208,442,371],{"class":222},[208,444,446,449,452,455,458,461,463,466,468,471,474,477,480,482,484],{"class":210,"line":445},14,[208,447,448],{"class":214},"      return",[208,450,451],{"class":222}," count ",[208,453,454],{"class":214},"+",[208,456,457],{"class":222}," (char.",[208,459,460],{"class":218},"codePointAt",[208,462,223],{"class":222},[208,464,465],{"class":238},"0",[208,467,438],{"class":222},[208,469,470],{"class":214},">",[208,472,473],{"class":238}," 0xFFFF",[208,475,476],{"class":214}," ?",[208,478,479],{"class":238}," 2",[208,481,343],{"class":214},[208,483,340],{"class":238},[208,485,486],{"class":222},")\n",[208,488,490,493,495],{"class":210,"line":489},15,[208,491,492],{"class":222},"    }, ",[208,494,465],{"class":238},[208,496,486],{"class":222},[208,498,500,502,505,508,510,512,514,516,518,520,523,525],{"class":210,"line":499},16,[208,501,322],{"class":214},[208,503,504],{"class":222}," ucs2Length ",[208,506,507],{"class":214},"\u003C=",[208,509,334],{"class":222},[208,511,337],{"class":214},[208,513,340],{"class":238},[208,515,343],{"class":214},[208,517,346],{"class":222},[208,519,349],{"class":218},[208,521,522],{"class":222},"(ucs2Length ",[208,524,257],{"class":214},[208,526,359],{"class":222},[208,528,530],{"class":210,"line":529},17,[208,531,532],{"class":222},"  }\n",[208,534,536],{"class":210,"line":535},18,[208,537,538],{"class":222},"}\n",[14,540,542],{"id":541},"hidden-cost-traps","Hidden Cost Traps",[10,544,545],{},"Several characters silently inflate your message size:",[147,547,548,561],{},[150,549,550],{},[153,551,552,555,558],{},[156,553,554],{},"Character",[156,556,557],{},"GSM-7 Cost",[156,559,560],{},"Notes",[166,562,563,574,599,610,624],{},[153,564,565,568,571],{},[171,566,567],{},"Basic letter (A–Z)",[171,569,570],{},"1 char",[171,572,573],{},"Normal",[153,575,576,593,596],{},[171,577,578,68,580,68,582,68,584,68,586,68,588,68,590],{},[34,579,78],{},[34,581,81],{},[34,583,67],{},[34,585,71],{},[34,587,49],{},[34,589,91],{},[34,591,592],{},"\\^",[171,594,595],{},"2 chars",[171,597,598],{},"Escape sequences",[153,600,601,604,607],{},[171,602,603],{},"Any emoji",[171,605,606],{},"Switches to UCS-2",[171,608,609],{},"Entire message affected",[153,611,612,619,621],{},[171,613,614,615,618],{},"Line break (",[34,616,617],{},"\\n",")",[171,620,570],{},[171,622,623],{},"Counts normally in GSM-7",[153,625,626,632,634],{},[171,627,628,629,618],{},"Carriage return (",[34,630,631],{},"\\r",[171,633,570],{},[171,635,636,637,639],{},"Often paired with ",[34,638,617],{}," (2 chars)",[10,641,642,643,646,647,650],{},"Smart quotes (",[34,644,645],{},"\"\"",") and em dashes (",[34,648,649],{},"—",") also force UCS-2 encoding — they are not in the GSM-7 alphabet. If you copy-paste text from Word or Google Docs, check for these characters.",[14,652,654],{"id":653},"practical-tips-for-sms-content","Practical Tips for SMS Content",[41,656,657,663,685,691,697,703],{},[44,658,659,662],{},[22,660,661],{},"Stick to GSM-7"," when possible — use straight quotes, basic punctuation, and no emoji",[44,664,665,668,669,671,672,432,674,671,676,679,680,671,683],{},[22,666,667],{},"Replace smart characters"," — convert ",[34,670,645],{}," to ",[34,673,645],{},[34,675,649],{},[34,677,678],{},"--",", and ",[34,681,682],{},"…",[34,684,417],{},[44,686,687,690],{},[22,688,689],{},"Count before sending"," — use a character counter that accounts for encoding switches",[44,692,693,696],{},[22,694,695],{},"Shorten URLs"," — use a link shortener to save characters (a typical URL consumes 30–80 characters)",[44,698,699,702],{},[22,700,701],{},"Avoid emoji in transactional SMS"," — they force UCS-2 and often render inconsistently across devices",[44,704,705,708],{},[22,706,707],{},"Test with your gateway"," — Twilio, MessageBird, and AWS SNS may handle encoding slightly differently",[14,710,712],{"id":711},"key-takeaways","Key Takeaways",[41,714,715,718,721,724,744,747],{},[44,716,717],{},"GSM-7 encoding allows 160 characters per SMS; UCS-2 allows only 70",[44,719,720],{},"A single emoji or special character forces the entire message into UCS-2",[44,722,723],{},"Concatenated messages reserve 6 bytes for the UDH, reducing GSM-7 to 153 and UCS-2 to 67 characters per segment",[44,725,726,727,432,729,432,731,432,733,432,735,432,737,432,739,432,741,743],{},"Escape characters in GSM-7 (",[34,728,78],{},[34,730,81],{},[34,732,67],{},[34,734,71],{},[34,736,49],{},[34,738,87],{},[34,740,91],{},[34,742,95],{},") count as two characters each",[44,745,746],{},"Smart quotes and em dashes from word processors silently switch encoding — sanitize input before sending",[44,748,749],{},"Use a character counter that detects encoding to avoid unexpected message splits and costs",[14,751,753],{"id":752},"related-guides","Related Guides",[41,755,756,763,769],{},[44,757,758],{},[759,760,762],"a",{"href":761},"\u002Fguides\u002Fcharacter-counting-guide","Character Counting Guide: Measuring Text Length Accurately",[44,764,765],{},[759,766,768],{"href":767},"\u002Fguides\u002Fword-count-best-practices","Word Count Best Practices for Writers and Editors",[44,770,771],{},[759,772,774],{"href":773},"\u002Fguides\u002Ftext-length-limits","Text Length Limits: Character Counts Across Platforms",[14,776,778],{"id":777},"try-it-yourself","Try It Yourself",[10,780,781,782,786],{},"Count your SMS characters accurately with our free ",[759,783,785],{"href":784},"\u002Ftools\u002Fcharacter-counter","Character Counter",". Paste your message, see the GSM-7 vs UCS-2 encoding, segment count, and remaining characters — all in real time.",[788,789,790],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":232,"depth":232,"links":792},[793,794,795,796,797,798,799,800],{"id":16,"depth":232,"text":17},{"id":106,"depth":232,"text":107},{"id":137,"depth":232,"text":138},{"id":541,"depth":232,"text":542},{"id":653,"depth":232,"text":654},{"id":711,"depth":232,"text":712},{"id":752,"depth":232,"text":753},{"id":777,"depth":232,"text":778},"2026-05-28","Understand how SMS encoding works — GSM-7 vs UCS-2, segmentation, and why emoji and special characters split your messages and increase costs.","md",{"immutable":279},"\u002Fguides\u002Fsms-character-counting-encoding",{"title":5,"description":802},"guides\u002Fsms-character-counting-encoding","acKzd5y2lB0P05t-ICeES2ZoGuGT3xt1b32CFPzbwCU",1780401336903]