با سلام
با چه پلاگینی به صورت ساده و بهینه اعداد میشه در صفحه را فارسی کرد
با سلام
با چه پلاگینی به صورت ساده و بهینه اعداد میشه در صفحه را فارسی کرد
var defaultSettings = "fa"; !function (e) { e.fn.persiaNumber = function (u) { "string" == typeof u && u.length > 0 && (defaultSettings = u); var r = 1728; function t(e, u) { e.find("*").andSelf().contents().each(function () { 3 === this.nodeType && "style" != this.parentNode.localName && "script" != this.parentNode.localName && (this.nodeValue = this.nodeValue.replace(this.nodeValue.match(/[0-9]*\.[0-9]+/), function (e) { return e.replace(/\./, ",") }), this.nodeValue = this.nodeValue.replace(/\d/g, function (e) { return String.fromCharCode(e.charCodeAt(0) + u) })) }) } "ar" == u && (r = 1584), window.persiaNumberedDOM = this, t(this, r), e(document).ajaxComplete(function () { t(window.persiaNumberedDOM, r) }) } }(jQuery), origParseInt = parseInt, parseInt = function (e) { return e = e && e.toString().replace(/[\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u 06F8\u06F9]/g, function (e) { return String.fromCharCode(e.charCodeAt(0) - 1728) }).replace(/[\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u 0668\u0669]/g, function (e) { return String.fromCharCode(e.charCodeAt(0) - 1584) }).replace(/[\u066B]/g, "."), origParseInt(e) }, origParseFloat = parseFloat, parseFloat = function (e) { return e = e && e.toString().replace(/[\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u 06F8\u06F9]/g, function (e) { return String.fromCharCode(e.charCodeAt(0) - 1728) }).replace(/[\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u 0668\u0669]/g, function (e) { return String.fromCharCode(e.charCodeAt(0) - 1584) }).replace(/[\u066B]/g, "."), origParseFloat(e) };
$('body').persiaNumber();
از این کد استفاده میکنم گوگل مپ هنگ میکنه و نقشه نشون داده نمیشه.
ولی اعداد فارسی می شوند
mvc
using System.IO;using System.Text;
using System.Web.Mvc;
namespace CustomActionFilters
{
public class En2FaConvertor : ActionFilterAttribute
{
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
var response = filterContext.HttpContext.Response;
if (response.ContentType == "text/html")
{
response.Filter = new En2FaStream(response.Filter);
}
}
}
public class En2FaStream : Stream
{
private Stream stream;
public En2FaStream(Stream responseStream)
{
stream = responseStream;
}
#region Properties
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override long Length
{
get { return 0; }
}
public override long Position { get; set; }
#endregion Properties
#region Methods
public override void Close()
{
stream.Close();
}
public override void Flush()
{
stream.Flush();
}
public override int Read(byte[] buffer, int offset, int count)
{
return stream.Read(buffer, offset, count);
}
public override long Seek(long offset, SeekOrigin origin)
{
return stream.Seek(offset, origin);
}
public override void SetLength(long value)
{
stream.SetLength(value);
}
#endregion
public override void Write(byte[] buffer, int offset, int count)
{
string html = Encoding.UTF8.GetString(buffer, offset, count);
html = En2Fa(html);
buffer = Encoding.UTF8.GetBytes(html);
stream.Write(buffer, 0, buffer.Length);
}
public string En2Fa(string str)
{
return str.Replace("0", "۰")
.Replace("1", "۱")
.Replace("2", "۲")
.Replace("3", "۳")
.Replace("4", "۴")
.Replace("5", "۵")
.Replace("6", "۶")
.Replace("7", "۷")
.Replace("8", "۸")
.Replace("9", "۹");
}
}
}
GlobalFilters.Filters.Add(new En2FaConvertor());
Application_Start()