.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Encoding.ASCII.GetString(bytes) return string with not expected

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
Example   byte[] bytes = {  0x36,0x92,0x30,0x94}; string rs=  Encoding.ASCII.GetString(bytes) ; //result rs = ?60?   Is Wrong Result; Result Right is     '60". So this function should fix to properly decode two symbols ' and " Code ASCII ' is 0x92,Code ACII for " is  0x94

View Complete Post

More Related Resource Links

How to count number of bytes in string for utf-8 encoding


How to find number of bytes in string in utf-8 encoding ?

str.Length returns number of characters but in utf-8 encoding some characters occupy more than 1 byte ? 

encoding/decoding a string to/from bitmap


I have two methods:

Encode - takes a string, converts it to array of bytes, uses bytes to specify colors, creates a color and sets a pixel based on bytes

Decode - takes a pixel, retrieves color (R,G,B) bytes and converts them to characters, that produces a string which was previously encoded

I'm using two for loops (img height/width) to specify position and access pixels

The issue is that once display (Control Panel\Appearance and Personalization\Display) changes to anything other then "Smaller - 100%",
bytes have different values during decoding, thus different string is produced (corrupted).

If the setting is set to "Smaller - 100%" the results are normal.

What can I do to avoid that problem?

Thanks in advance

HtmlHelperExtensions in MVC2 return a HTML string, unencoded. In MVC3 this tring is encoded!

 HtmlHelperExtensions in MVC2 return a HTML string, unencoded. In MVC3 this string is encoded! How can I return unencoded HTML to a Razor view in MVC3? 

infopath 2007 Expected value type: end-of-string ! calculated field

Hello I am using infopath since there is no field with type date and time in InfoPath 2007. I created three fields one for date one, for hours, and one for minutes then I created forth field that concatenate the values of the three fields this field will be used as column in form template library used by my form. All seems good so far but when I tried to concatenate those fields go the following error Expected value type: end-of-string how can I solve this ? my xpath looks like ../my:calmomoDate../my:cbmomoHours:../my:cbmomoMunites Thanks  Momo

Simple ASP.NET SOAP request to return string



I have a requirement to build a simple ASP.NET web page which sends some parameters to a web service, and then displays the string which was returned.

I'm a complete .NET newby and the only examples I can find seem really really complex.  I just need something mega simple, but which an handle parameters being sent to the web service.  Can anyone point me in the direction of a simple bit of C# which will do this with no frills or fuss?

Any help much appreciated, thanks!

How to return a string value to code behind?

How to get a string value from a stored procedure to the code behind of ASP.net with C#

encoding function parameters and return values when binaryMessageEncoding is used


Dear All,

I'm creating simple web service that will accept some parameters (such as customer name and file name) and return content of an xml file as a string and WS client will save it on his side. I'm using custom binding with binaryMessageEncoding and httpTransport. The question is if it is possible to have these input parameters as well as returned xml content binary encoded somehow?

Thanks in advance for your help!


help encoding a string like this: The%20Best%20Place%20in%20Vancouver


how do I convert a string like this: "The Best Place in Vancouver " to this -> The%20Best%20Place%20in%20Vancouver





Pondering ASCII ordering in a string comparison



The following query on SQL Server:

Select case when '9:9' < '99' then 1 else 0 end
returns 1

Given, according to http://asciitable.com/ ':' comes after '9' I am surprised that the above query does what it does. Then again I'm clearly making a wrong assumption somewhere.

Can anyone explain this?




http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | About me
Jamie Thomson

ASCII string to integer grouping equivalent?


Hi I have been trying unsuccssfully to convert a column of data (mycolumn) from a table (mytable)  that has ascii character strings comprised of characters numbered from 0-255. I need to be able to group the numeric values for each ascii string from each record, into what I call an integer group and write that value back to a different column for each respective record in the table. But, I can't figure out how to modify the following Microsoft code to perform this:



-- Create the variables for the current character string position 

-- and for the character string.

DECLARE @position int, @string char(15)

-- Initialize the variables.

SET @position = 1 

SET @string = 'Du monde entier' --here I don't know how to pass a selected column to the @string

WHILE @position <= DATALENGTH(@string) --here I need to know how to loop through each records ascii string and group the values


 SELECT ASCII(SUBSTRING(@string, @position, 1)),

  CHAR(ASCII(SUBSTRING(@string, @position, 1)))

 SET @position = @position + 1


SET NOCOUNT OFF -- then down here somewhere I need to write each converted string to integers back to the myintegerGroup column


The output from above is below, But I need grouped examp: Du monde entier => 681173210911111010010132101110116105101114


Byte array -> String encoding

Greetings and sorry for the likely newbie question.  I also hope this is in the right forum!

What's the most "pure" way to encode a Byte array into a String?  I've performed several searches but none have yielded much insight into my particular problem.  I'm using C++, COM Interop into a VB6 application that uses a String return for socket class, but the actual issue is in the .NET native code.

  Encoding::ASCII->GetString(byteArray, 0, iNumBytes)
.. converts values >7 bits to a replacement value... and

  Encoding::UTF8->GetString(byteArray, 0, iNumBytes)
.. truncates the higher value chars from the conversion totally..

And obviously Unicode things the string is 1/2 it's actual size which makes parsing for markers in said data a real chore.  The byte streams are about 90% text and 10% binary (with markers/tags).

String containers seem to be able to do what I need them to do as manually initializing them, they get back up to the VB6 app without any problems.  It's just how to get these Byte arrays into them that's the problem.

Replacing the VB6.0 app to use something other than String would also be less than ideal as it's usage wasn't coded very managebly either and is widespread in a very, very large application.

The Byte array is from Socket class operations.  I'm unsure if there is a

Can a serviceHander return a String instead of an XmlElement?



I am looking for suggestions to improve performance of my visual basic code.

I am using Visual Studio 2008 to create a Visual Basic application that requests and receives data from a server, using the SOAP interface.  The payload is XML data.

I've created a "Service Reference" to handle these communications using the "Add Service Reference" dialogue,  specifying my  WSDL file in the "Address:" field.

Visual Studio successfully generates a vb file that contains the definitions for the interface, in particular the function  "serviceHandler".

To initiate a transaction I code:

   Dim SoapData  As New  WebService.DelegateClient
   Dim Reply As Xml.XmlElement

   Reply = SoapData.serviceHandler(....)

The "Reply" variable is successfully populated with nodes describing the XML tags and contents.

It is desired to place the  XML payload into a string variable.  This is done like so:

   Dim MyString As String  =  Reply.InnerText

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Connestion string create any database server

This links important to how to create connection string to any data base sever.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

Built-in Functions - String Functions

String functions let you extract various portions of character strings, change the case of strings, concatenate and reverse strings and perform many other types of manipulations. All built-in string functions are deterministic with the exception of CHARINDEX and PATINDEX

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend