convert byte[] to String and string to byte[] note encoding and decoding required....

hi all,

       As the subject, can I have solution ofr the same.......

 e'i Convert byte[] into string and strting into byte[] , can i have teh sample page.

 

 

 

 


Thanks & Regards,
Murthy.
0
murthysrn
11/3/2008 11:01:49 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

9 Replies
1183 Views

Similar Articles

[PageSpeed] 43

         System.Text.Encoding.Unicode.GetString(ByteArray);//Byte Array to String
            System.Text.Encoding.Unicode.GetBytes(String);//String to Byte Array


We All move to our original place.
Don't forget.

Imran Baloch
0
imran_ku07
11/3/2008 12:07:08 PM

thanks for reply..

 

  in this methods I  will loss the data.... 

  Can you have any other way....... 

 

 

  


Thanks & Regards,
Murthy.
0
murthysrn
11/3/2008 12:11:39 PM

murthysrn:

 

  in this methods I  will loss the data...

 

What do U mean? 


We All move to our original place.
Don't forget.

Imran Baloch
0
imran_ku07
11/3/2008 12:18:23 PM

    I have an Image Files in databsae of length 1500 to 2000 dimentions.....byte array lengh....

 I want to tranfer that into  server....but in the server  copied length will be some 200- 300 byte array length of lenth of the byte array

 

if it is encoded how can I decode it...? 

 


Thanks & Regards,
Murthy.
0
murthysrn
11/3/2008 12:36:56 PM

What about FileStream

http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx

We All move to our original place.
Don't forget.

Imran Baloch
0
imran_ku07
11/3/2008 12:43:23 PM

What About this,

System.IO.StreamReader r = new System.IO.StreamReader("YourDatbaseStream");string StringContent = r.ReadToEnd();

r.Close();

please don't forget to check "Answer" if it helps you


We All move to our original place.
Don't forget.

Imran Baloch
0
imran_ku07
11/4/2008 5:06:45 AM

Hi,

string[]  strArr = new string[3];

strArr[0]  = clsTransactionData.ByteToString(objSend._byteImages);

byte array is 31052 length but I am getting only string of length of 52.

even all the string I am getting of length of 52 with static string value..? 

 ------------------------------------------------------------------------

public static string ByteToString(byte[] pbytSource)
        {
            if (pbytSource == null)
            {
                return "";
            }
            else
            {
                string _str = Encoding.ASCII.GetString(pbytSource, 0, pbytSource.Length);
                return _str;
            }
        }   


Thanks & Regards,
Murthy.
0
murthysrn
11/12/2008 7:33:40 AM

 I think you should use array of string to hold all,

 string[]  strArr=clsTransactionData.ByteToString(objSend._byteImages);

 


We All move to our original place.
Don't forget.

Imran Baloch
0
imran_ku07
11/12/2008 7:57:02 AM

Hi Imron,

thanks a lot,

I used as follows,....  it is working fine...thaks  again

---------------------------------------------------------------------------------------------------------------------

public static byte[] StringToByte(string pstrSource)

{

if (pstrSource == "")

{

return null;

}

else

{

return Encoding.ASCII.GetBytes(pstrSource);

}

}

public static string ByteToString(byte[] pbytSource)

{

if (pbytSource == null)

{

return "";

}

else

{

return Encoding.ASCII.GetString(pbytSource, 0, pbytSource.Length);

}

}


Thanks & Regards,
Murthy.
0
murthysrn
11/13/2008 12:14:29 PM
Reply:

Similar Artilces:

String to Linq.Byte and Linq.Byte to String convertion?
 Hi, I have a field in my database as image type. I am using Linq to read/insert records.I am having little hard time inserting text(string) into the image field and then converting back to string.Do you have any suggestions? Thanks in advance,   The below example shows how to convert Linq Binary to byte If Not String.IsNullOrEmpty(HttpContext.Current.Request.QueryString("imageID")) Then Dim imageID = HttpContext.Current.Request.QueryString("imageID") Dim db As New AuctionsDataContext Dim result = From img In db.Image...

RSA Encryption
Here is my goal:1. Take a string2. Encrypt it 3. Pass it as a parameter in the QueryString4. Decrypt it The value starts as a string, then is converted to a byte[] and then encrypted.  The resulting byte[] is converted to a string and send as a parameter.  The recieving page decrypts the string (creates a byte[], decrypts to a new byte[], and the value is finally parsed for its values) I am using http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographyrsacryptoserviceproviderclasstopic.asp with a small modification t...

How to append string to Response.OutputStream after string converted to byte array
Hi, I am trying to append string to Response.OutputStream property in PostRequestHandlerExecute event handler inside custom httpmodule. The goal of this implementation is to append string to output stream after the page is rendered when the response object is still held on the server. The pseudo code I wrote is the following: private void PostRequestHandlerExecute(object sender, EventArgs e) { HttpApplication application = ( HttpApplication ) sender; HttpContext context = application.Context;   string s = "This is test!"; byte[] buffer = Encoding.ASCII.GetByt...

Converting bytes to string
Hi guys,I'm currently trying to insert image into my SQL db.  I have tried a number of methods that were posted online, and so far with no luck.My current code reads:                     Dim conn As New Data.SqlClient.SqlConnection()                    conn.ConnectionString = ConfigurationManager.ConnectionStrings("MainDBConnection").ToString        &nbs...

Am I correct in thinking that the only way to get ord() to return a value over 256 is to send the character as a Unicode string instead of a byte string?
In other words, is there any character that will make ord() return over = 256 when passed in as a byte string? For example, note the differences in output between a unicode string and = a byte string regarding character 257, as a unicode string it is 257, as = a byte string it is 196. $ perl -C6 -le 'print "Character 257 info:";print "\tunicode \\x{} = notation: " . sprintf(q{\x{%x}}, 257);print "\tOutput as Unicode string = \x{101}";print "\tunicode string \\x{} notation ord(): " . = ord("\x{101}");print "\tbyte string gr...

string to byte array
Hi all, I'm currently building a small app which uses 3DES encryption, it works all nicely, but would like to do a bit a fix upcurrently the code behind has the code as followDim key As Byte() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22.2, 23, 24}and the web.config is as follows    <appSettings>    <add key="key" value="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22.2, 23, 24"/>    </appSettings> I am trying to call the values {1, 2 ,...

To Encode String or to Not Encode String... Answer?
I am importing a CSV file from a Unix server as a string, and then saving the string into a new file for later processing.  However, this process does not always work.  As this CSV file is VERY, VERY large, I am unable to immediately tell if the fault lies with my code, or the CSV file provider (very possible).  The only time I can tell that this happened is when the data is not populated the next morning.  The fault appears to lie in there being extra or missing commas, as when I try to run the data import manually, STRINGs are attempted to be inserted into INT...

How do I convert string to a byte array?
[see also http://forums.sybase.com/cgi-bin/webnews.cgi?cmd=item-232695&group=sybase.public.powerbuilder.general] Working with an old OLE object for TCP comm, and the unicode vs ANSI charset change at PB 10 seems to be causing issues. BUT! the old object avoids "'wide' to ANSI" conversion and just sends what it's handed if it's handed a BYTE Array. However, getting there from a string seems to involve conversion to and parsing from a Blob, something that I'm fumbling. Some help on this conversion process would be appreciated. Convert the string to ...

How to convert an Int32 or an Int to a byte (encoded 8 bytes) ?
He, How to convert an Int32 or an Int to a byte (encoded 8 bytes) ? for examle convert 2 (Int32) to a byte 00000001 Best regardsf Friend, if you want to convert to a byte array, here is the code Dim arr as byte()arr = BitConverter.GetBytes(MyInt) Here MyInt is you Int32 variable Else you can try this also http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=788 Hope it helped you. Good luck!  Please Don't forget to click "Mark as Answer" on the post that helped you.This can be beneficial to other community members reading the thread. Convert.ToByte(12) ...

string and string[]
hello, whats the difference here between string and string[] thanks "string" denotes an item of type String "string[]" denotes an array of type String itemsThanks, EdMicrosoft MVP - ASP/ASP.NET Gracia mon ami...

Problems converting a byte array to string
Hello,i need some help on this one, i have a byte array with some information i get from an UDP serverhere is an example of what my code looks like Dim b() As Byte = {0, 179, 68, 252, 255, 128, 234, 244} Dim s As String = System.Text.Encoding.Default.GetString(b) Debug.WriteLine(s) Now if notice the first byte is 0, when this happens my result string will be nothingAny ideas on how to fix this?Thank you   I notice you're using encoding Default... 0 is often a string terminator, which could be your issue. Maybe try some of the other encodings until you find one that fi...

how to convert hex string to hex bytes?
Hi I've been trying and haven't found a solution for this yet and hopefully some of you can give me a direction to solve this problem. I have a string in hex representation i.e, 64 chars 'AB23FFFE.....' How can I convert it to 32 chars String where each byte is $AB $23 $FF $FE .... ? Even if I do it manually, can I store the hex(non ASCII) to String? Thanks for looking!! edwin wrote: > I have a string in hex representation i.e, 64 chars 'AB23FFFE.....' > How can I convert it to 32 chars String where each byte is $AB $23 $FF > $FE .... ? Th...

How to convert a String to a byte array? [Edit]
Hi, I want to send a string (UnicodeString typed variable) over the serial port. I have to convert the string to a byte array, which I can write to the serial port. The project options _TCHAR maps to wchar_t. Thus, how to convert a String to a byte array in C++ Builder 2010? On Microsoft Developer Network I have found: Byte unicodeBytes[] = unicode -> GetBytes(unicodeString); You can investigate it your self here: http://msdn.microsoft.com/en-us/library/system.text.encoding.convert%28VS.71%29.aspx Please do not hesitate to answer or comment this issue. All help is appreci...

byte to string
Hi all, How do I represent: Dim HashedDataBytes As Byte() Dim Encoder As New UTF8Encoding() Dim md5Hasher As New MD5CryptoServiceProvider() HashedDataBytes = md5Hasher.ComputeHash(Encoder.GetBytes(aStr)) HashedDataBytes as a String? Cheers, D. Convert.ToBase64String(HashedDataBytes) Here is the function I use to create MD5 hashes, if that is what you are trying to do Public Shared Function createMD5(ByVal SourceText As String) As String 'Create an encoding object to ensure the encoding standard for the source text Dim Ue As New UnicodeE...

Web resources about - convert byte[] to String and string to byte[] note encoding and decoding required.... - asp.net.getting-started

Encoding (memory) - Wikipedia, the free encyclopedia
Visual, acoustic, and semantic encodings are the most intensively used. Other encodings are also used. Acoustic encoding is the encoding of auditory ...

Twitter image encoding challenge
If a picture's worth 1000 words, how much of a picture can you fit in 140 characters? Note : That's it folks! Bounty deadline is here, and after ...

【medical-news】Genetic Variation in NR1H4 Encoding the Bile Acid Receptor FXR - 医药生命科学动态跟踪 -丁香园论坛
Context: Bile acid signaling via farnesoid X receptor (FXR) regulates glucose and lipid levels, fat mass, and hepatic steatosis in animal models.Objective: ...

HandBrake Open Source video transcoder v0.10 released with hundreds of new features including H.265 and ...
... can be used for transcribing many different types of files/codecs to almost any other. Today’s headliner updates include H.265 and VP8 encoding. ...

CJK Type - CJK Fonts, Character Sets & Encodings. All CJK. All of the time.
As I wrote nearly a year ago , the Adobe-Identity-0 ROS is useful for building special-purpose fonts, especially CJK ones whose glyph coverage ...

Link Encoding Goes Mobile With Deep Links From Bitly
... Facebook and Google have been competing to bring the best solution for tracking deeplinks . This week, Bitly announced its own linking encoding ...

Encoding Articles - AppAdvice iPhone/iPad News
Latest Encoding Articles - AppAdvice iPhone/iPad News

AirMovie - Enjoy the videos in your PC anytime, anywhere with NO ENCODING!!
Holen Sie sich „AirMovie - Enjoy the videos in your PC anytime, anywhere with NO ENCODING!!“ im App Store. Sehen Sie sich Screenshots, Bewertungen ...

More tips on encoding video for Apple TV and iPod, from us to you
Apple tells video podcasters how to encode their content, which is also useful …

Handbrake 0.9.6 gives some, takes some encoding features
The Handbrake Project has announced an update to its open-source, cross-platform video transcoding utility. Handbrake 0.9.6 includes new and ...

Resources last updated: 12/15/2015 9:43:59 PM