VB Script 2 CS

shahab

Junior Contributor
Joined
Aug 14, 2003
Messages
206
Location
Iran(Middle East)
I have a function in VB Script but I can not covert it to CS!
Help me please:
Function En2Fr (sStr)

Dim nLen, i, ch, sFrStr

nLen = Len(sStr)

if nLen = 0 OR IsNull(nLen) then
En2Fr = sStr
Exit Function
end if

sFrStr = ""

for i = 1 to nLen
ch = Mid(sStr, i, 1)
if 48 <= Asc(ch) AND Asc(ch) <= 57 then
ch = ChrW(Asc(ch) + 1728)
end if
sFrStr = sFrStr + ch
next

En2Fr = sFrStr

End Function
 
shahab said:
I have a function in VB Script but I can not covert it to CS!
Help me please:
this method will do the following:

En2Fr("0123456789") -> "۰۱۲۳۴۵۶۷۸۹"

PHP:
public string En2Fr (string sStr) 
{
   if (sStr == null)
	  return sStr; 
   string s = "";
   for (int i = 0; i < sStr.Length; i++) 
	  s += (48 <= ((ushort)sStr[i]) ) && (((ushort)sStr[i]) <= 57) ? 
						(char)(((ushort)sStr[i]) + 1728) : sStr[i];
   return s;
}

God, I love C#!!!!
 
Last edited:
Back
Top