Title: Javascript’s Unicode Problem
Open Graph Title: Javascript’s Unicode Problem
X Title: Javascript’s Unicode Problem
Open Graph Description: A while ago I needed a simple string pad function, and since it’s a freakishly simple task, I just wrote a simple function: function limit(str, limit = 16, padString = "#", padPosition = "right") { const strLength = str.length; if (strLength > limit) { return str.substring(0, limit); } else if (strLength < limit) { const padRepeats
X Description: A while ago I needed a simple string pad function, and since it’s a freakishly simple task, I just wrote a simple function: function limit(str, limit = 16, padString = "#", padPosition = "right") { const strLength = str.length; if (strLength > limit) { return str.substring(0, limit); } else if (strLength < limit) { const padRepeats
Opengraph URL: https://sallar.dev/javascripts-unicode-problem/
Generator: Ghost 5.130
Domain: sallar.dev
{
"@context": "https://schema.org",
"@type": "Article",
"publisher": {
"@type": "Organization",
"name": "Made by Sallar",
"url": "https://sallar.dev/",
"logo": {
"@type": "ImageObject",
"url": "https://sallar.dev/content/images/2026/05/made-by-sallar-mono-1.svg"
}
},
"author": {
"@type": "Person",
"name": "Sallar",
"image": {
"@type": "ImageObject",
"url": "https://sallar.dev/content/images/2026/05/ChatGPT-Image-Apr-23--2026--07_49_10-PM.PNG",
"width": 1086,
"height": 1448
},
"url": "https://sallar.dev/author/sallar/",
"sameAs": []
},
"headline": "Javascript’s Unicode Problem",
"url": "https://sallar.dev/javascripts-unicode-problem/",
"datePublished": "2016-08-16T18:42:00.000Z",
"dateModified": "2026-05-02T21:36:54.000Z",
"keywords": "Javascript",
"description": "A while ago I needed a simple string pad function, and since it’s a freakishly simple task, I just wrote a simple\n\nfunction:\n\n\nfunction limit(str, limit = 16, padString = "#", padPosition = "right") {\n const strLength = str.length;\n\n if (strLength > limit) {\n return str.substring(0, limit);\n } else if (strLength < limit) {\n const padRepeats = padString.repeat(limit - strLength);\n return (padPosition === "left") ? padRepeats + str : str + padRepeats;\n }\n return",
"mainEntityOfPage": "https://sallar.dev/javascripts-unicode-problem/"
}
| None | IE=edge |
| referrer | no-referrer-when-downgrade |
| og:site_name | Made by Sallar |
| og:type | article |
| article:published_time | 2016-08-16T18:42:00.000Z |
| article:modified_time | 2026-05-02T21:36:54.000Z |
| article:tag | Javascript |
| twitter:card | summary |
| twitter:url | https://sallar.dev/javascripts-unicode-problem/ |
| twitter:label1 | Written by |
| twitter:data1 | Sallar |
| twitter:label2 | Filed under |
| twitter:data2 | Javascript |
Links:
Viewport: width=device-width, initial-scale=1