Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Shared Function ResolveCharacterSound(ByVal c As Char) As String
            Dim str As String = "" & c
            Dim totalCoreSoundCharacter As Integer = 0
            If isPunct(c) Then
                Return str
            ElseIf isDigit(c) Then
                Return "" & CChar("०") ("०"c + (c - "0"c))
            ElseIf isConsonent(str(0), False) Then
                Return "" & GetCoreSound(str, totalCoreSoundCharacter) & "्"
            Else
                Return "" & GetCoreSound(str, totalCoreSoundCharacter)
            End If
        End Function


*************************************************
VB
Public Shared Function DoTransLitrate(ByVal str As String) As String
            Dim i As Integer = 0
            Dim ret As String = ""
            Dim pi As Integer = 0
            Dim vowelFlag As Boolean = False
            str = str.ToLower()
            While i < str.Length

                Try

                    If (str(i) = "h"c AndAlso vowelFlag) OrElse (isConsonent(str(i), vowelFlag) AndAlso i > 0) OrElse (str(i) = " "c) OrElse isPunct(str(i)) OrElse isDigit(str(i)) OrElse ((i - pi) > 5) Then
                        If pi < i Then
                            ret += GetSound(str.Substring(pi, i - pi))
                        End If
                        If str(i) = " "c Then
                            ret += " "c
                        End If
                        If ((str(i) = " "c) OrElse isPunct(str(i))) Then
                            ret += str(i)
                            pi = i + 1
                        ElseIf isDigit(str(i)) Then
                            Dim digi As String = "" & CChar("०") c + (str(i) - "0"c))
                            ret += digi
                            pi = i + 1
                        Else
                            pi = i
                        End If

                        vowelFlag = False
                    ElseIf isVowel(str(i)) AndAlso str(i) <> "h"c Then
                        vowelFlag = True
                    End If
                    i += 1
                Catch exp As Exception
                    ret += "error!!"
                End Try
            End While
            If pi < i Then
                Try
                    ret += GetSound(str.Substring(pi, i - pi))
                Catch exp As Exception
                    ret += "error!!"
                End Try
            End If
            Return SuperTrim(ret)
        End Function
Posted
Updated 25-May-11 3:39am
v2

Technically it is a repost[^]. Take hints from the previous question answer you had and try out.

Further, all you need is to give the code line and around about details instead of whole code to get an answer.

Have a look at this chart and use it as per need: VB.NET and C# Comparison[^]
 
Share this answer
 
Comments
apeksha4deshpande 25-May-11 5:18am    
thanks
Espen Harlinn 25-May-11 16:39pm    
Nice reply, my 5
can you update original a source code of c# to understand more.

Thank you.
 
Share this answer
 
Comments
apeksha4deshpande 25-May-11 12:37pm    
In C#

static string ResolveCharacterSound(char c)
{
string str = "" + c;
int totalCoreSoundCharacter=0;
if(isPunct(c))
{
return str;
}
else if (isDigit(c))
{
return "" + (char)('०' + (c - '0'));
}
else if (isConsonent(str[0], false))
{
return "" + GetCoreSound(str,ref totalCoreSoundCharacter) + "्";
}
else
{
return "" + GetCoreSound(str,ref totalCoreSoundCharacter);
}
}
******************************
public static string DoTransLitrate(string str)
{
int i=0;
string ret="";
int pi = 0;
bool vowelFlag = false;
str = str.ToLower();
while (i<str.length)
{

="" try
="" if="" ((str[i]="=" 'h'="" &&="" vowelflag)="" ||="" (isconsonent(str[i],="" i=""> 0)
|| (str[i] == ' ')
|| isPunct(str[i])
|| isDigit(str[i])
|| ((i - pi) > 5))
{
if (pi < i)
{
ret += GetSound(str.Substring(pi, i - pi));
}
if (str[i] == ' ')
{
ret += ' ';
}
if (((str[i] == ' ') || isPunct(str[i])))
{
ret += str[i];
pi = i + 1;
}
else if(isDigit(str[i]))
{
string digi = "" + (char)('०' + (str[i] - '0'));
ret += digi;
pi = i + 1;
}
else
{
pi = i;
}
vowelFlag = false;

}
else if (isVowel(str[i]) && str[i] != 'h')
{
vowelFlag = true;
}
++i;
}
catch (Exception exp)
{
ret += "error!!";
}
}
if (pi < i)
{
try
{
ret += GetSound(str.Substring(pi, i - pi));
}
catch (Exception exp)
{
ret += "error!!";
}
}
return SuperTrim(ret);
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900