How can I scan a string to determine if it contains DBCS chars?

Platform: ASP.NET| Category: Miscellaneous

VB.NET


Public Shared Function IsAsciiString(s As [String]) As Boolean
   Dim i As Integer
   For i = 0 To s.Length - 1
      Dim ch As Char = s(i)
      If ch < 0 Or ch > 127 Then
         Return False
      End If
   Next  
   Return True
End Function ’IsAsciiString

’In Page_Load
dim originalString  as string = 'a±' 
Response.Write (IsAsciiString(originalString)) 

C#


public static bool IsAsciiString(String s) 
{ 
	for (int i = 0; i < s.Length; i++)
	{
		char ch = s[i];
		if (ch < 0 || ch > 127) return false; 
	} 
	return true; 
} 
//In Page_Load
String originalString = 'a±' ;
Response.Write (IsAsciiString(originalString));

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.