Я получил следующую процедуру на сервере sql и .net.
Преобразование английского языка в гуджаратский Unicode и
Конвертировать гуджаратский Unicode в английские цифры
.net Код
public static class global
{
public static string Translate(string source, string fromStr, string toStr)
{
string result = "";
foreach (var sourceChar in source)
{
int pos = fromStr.IndexOf(sourceChar);
if ((pos >= 0) && (pos < toStr.Length))
{
result += toStr[pos];
}
}
return result;
}
public static string ToGujDig(this object source)
{
string fromStr = ".0123456789";
string toStr = ".\u0AE6\u0AE7\u0AE8\u0AE9\u0AEA\u0AEB\u0AEC\u0AED\u0AEE\u0AEF\u0AF0";
string result = "";
string s = source.ToString();
foreach (var sourceChar in s)
{
int pos = fromStr.IndexOf(sourceChar);
if ((pos >= 0) && (pos < toStr.Length))
{
result += toStr[pos];
}
}
return result;
}
public static string ToEngDig(this string source)
{
string fromStr = ".\u0AE6\u0AE7\u0AE8\u0AE9\u0AEA\u0AEB\u0AEC\u0AED\u0AEE\u0AEF\u0AF0";
string toStr = ".0123456789";
string result = "";
string s = source.ToString();
foreach (var sourceChar in s)
{
int pos = fromStr.IndexOf(sourceChar);
if ((pos >= 0) && (pos < toStr.Length))
{
result += toStr[pos];
}
}
return result;
}
}
sql код сервера
передать числовое значение и получить значение Unicode
CREATE FUNCTION [dbo].[NumericToUnicode]
(
@String VARCHAR(50)
)
RETURNS NVARCHAR(50)
BEGIN
DECLARE @rString NVARCHAR(50)
set @rString= N''
DECLARE @length INT
set @length = LEN(@String)
DECLARE @position INT
set @position= 1
WHILE @position <= @length
BEGIN
IF (ASCII(SUBSTRING(@String, @position, 1))) = 46
SET @rString = @rString + N'.'
ELSE
SET @rString = @rString + NCHAR(ASCII(SUBSTRING(@String, @position, 1)) + 2742)
SET @position = @position + 1
END
RETURN @rString
END
-- Test it
SELECT [dbo].[NumericToUnicode]('50.0') or
SELECT [dbo].[NumericToUnicode](50.12)
Передать значение Unicode и получить числовое значение
Create FUNCTION [dbo].[UnicodeToNumeric]
(
@nString NVARCHAR(50)
)
RETURNS NUMERIC(12,2)
BEGIN
DECLARE @rString NVARCHAR(50)
set @rString=''
DECLARE @position INT
set @position=1
WHILE @position <= LEN(@nString)
BEGIN
IF (UNICODE(SUBSTRING(@nString, @position, 1))) = 46
SET @rString = @rString + CHAR(UNICODE(SUBSTRING(@nString, @position, 1)))
ELSE
SET @rString = @rString + CHAR(UNICODE(SUBSTRING(@nString, @position, 1)) - 2742)
SET @position = @position + 1
END
RETURN @rString
END
Надеюсь, это поможет.