473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

AscW Equivalent

VB has the AscW function. There is no corresponding C# function. How can I do
this in C#? I do not want to reference the Microsoft.VisualBasic namespace
for just this function.

Oct 19 '07 #1
6 10986
Richard,

You can just convert the character to an integer, and it will give you
the same thing (or, if you are talking about the version that takes a string
and not a character, use the first character in the string).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Richard" <Ri*****@discussions.microsoft.comwrote in message
news:D9**********************************@microsof t.com...
VB has the AscW function. There is no corresponding C# function. How can I
do
this in C#? I do not want to reference the Microsoft.VisualBasic namespace
for just this function.

Oct 19 '07 #2
Richard <Ri*****@discussions.microsoft.comwrote:
VB has the AscW function. There is no corresponding C# function. How can I do
this in C#? I do not want to reference the Microsoft.VisualBasic namespace
for just this function.
What *exactly* do you want to do? Bear in mind that every char is
already in Unicode. Are you trying to convert text into the default
encoding for the platform?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 19 '07 #3
Hi Jon,

I'm converting the Web Log Analyzer Starter Kit from VB to C#. In the
following procedure, I'm stuck on the line to convert the AscW logic below:

Public Function Parse(ByVal logFileName As String) As List(Of LogFileEntry)
' A collection representing all valid entries in the log file.
Dim logFileEntries As New List(Of LogFileEntry)

' Remember the name of the log file. This is needed later to
generate error messages.
m_logFileName = logFileName

' Read the contents of the file line by line and parse each line.
Using reader As New StreamReader(logFileName)
Do
Dim line As String = reader.ReadLine()
' If there are no more lines then exit the loop.
If (line Is Nothing) Then Exit Do

' If the first character is a 0 byte then exit the loop. This
may happen if IIS
' is still writing to the log file.
If (line.Length 0) AndAlso (AscW(line.Chars(0)) = 0) Then
Exit Do

' If the first character is a # then this is a directive
otherwise it is an entry.
If line.StartsWith("#") Then
ParseDirective(line)
Else
Dim access As LogFileEntry = ParseLogEntry(line)
' If the line was successfully parsed add the
LogFileEntry object to a collection.
If access IsNot Nothing Then
logFileEntries.Add(access)
End If
End If
Loop
End Using

' Return the collection of LogFileEntry objects.
Return logFileEntries
End Function

"Jon Skeet [C# MVP]" wrote:
Richard <Ri*****@discussions.microsoft.comwrote:
VB has the AscW function. There is no corresponding C# function. How can I do
this in C#? I do not want to reference the Microsoft.VisualBasic namespace
for just this function.

What *exactly* do you want to do? Bear in mind that every char is
already in Unicode. Are you trying to convert text into the default
encoding for the platform?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 19 '07 #4
Richard <Ri*****@discussions.microsoft.comwrote:
I'm converting the Web Log Analyzer Starter Kit from VB to C#. In the
following procedure, I'm stuck on the line to convert the AscW logic below:
Just check for the first character of the line being '\0'.

if (line.Length 0 && line[0]=='\0')
{
break;
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 19 '07 #5
Thanks Jon!

"Jon Skeet [C# MVP]" wrote:
Richard <Ri*****@discussions.microsoft.comwrote:
I'm converting the Web Log Analyzer Starter Kit from VB to C#. In the
following procedure, I'm stuck on the line to convert the AscW logic below:

Just check for the first character of the line being '\0'.

if (line.Length 0 && line[0]=='\0')
{
break;
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 23 '07 #6
Thanks Nicholas!

"Nicholas Paldino [.NET/C# MVP]" wrote:
Richard,

You can just convert the character to an integer, and it will give you
the same thing (or, if you are talking about the version that takes a string
and not a character, use the first character in the string).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Richard" <Ri*****@discussions.microsoft.comwrote in message
news:D9**********************************@microsof t.com...
VB has the AscW function. There is no corresponding C# function. How can I
do
this in C#? I do not want to reference the Microsoft.VisualBasic namespace
for just this function.



Oct 23 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
3
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
7
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
10
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
2
by: Vic | last post by:
Do we have the visual basic.Net equivalent for ASC and ASCW or do I have to reference the Microsoft.VisualBasic.Strings ?? Thanks, Vic
17
by: Mike Labosh | last post by:
I would really rather use the "dot-nettified" syntax rather than digging global functions out of Microsoft.VisualBasic. Anyone know the newfangled way to achieve the same results? -- Peace &...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.