toLocaleString хорош, но не работает во всех браузерах. Я обычно использую currencyFormatter.js ( https://osrec.github.io/currencyFormatter.js/ ). Это довольно легкий и содержит все определения валюты и локали прямо из коробки. Это также хорошо для форматирования необычно отформатированных валют, таких как INR (который группирует числа в lakhs и crores и т. Д.). Также нет зависимостей!
OSREC.CurrencyFormatter.format(2534234, { currency: 'INR' });
// Returns ₹ 25,34,234.00
OSREC.CurrencyFormatter.format(2534234, { currency: 'EUR' });
// Returns 2.534.234,00 €
OSREC.CurrencyFormatter.format(2534234, { currency: 'EUR', locale: 'fr' });
// Returns 2 534 234,00 €
It means you tried to create a string bigger than std::string::max_size().
http://msdn.microsoft.com/en-us/library/as4axahk(VS.80).aspx
An exception of type length_error Class is thrown when an operation produces a string with a length greater than the maximum size.