We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cloudflare-mcp-apps/ads-roi'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
ucs2-length.ts•656 B
/**
* Get UCS-2 length of a string
* https://mathiasbynens.be/notes/javascript-encoding
* https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
*/
export function ucs2length(s: string): number {
let result = 0;
let length = s.length;
let index = 0;
let charCode: number;
while (index < length) {
result++;
charCode = s.charCodeAt(index++);
if (charCode >= 0xd800 && charCode <= 0xdbff && index < length) {
// high surrogate, and there is a next character
charCode = s.charCodeAt(index);
if ((charCode & 0xfc00) == 0xdc00) {
// low surrogate
index++;
}
}
}
return result;
}