473,763 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string byte dump

Does anyone that knows python want to write me a byte dump for strings? :-)

I am trying to modify a plugin (that someone else wrote) that uses
interprocess communication.
It works on strings without special characters but it fails on other
stings like "Björk".

It calls decode('utf8') but I guess the strings are not utf8 so I need
to find out what is being input.
Jan 28 '07 #1
3 1833
Jammer <as****@mail.co mwrites:
Does anyone that knows python want to write me a byte dump for strings? :-)

I am trying to modify a plugin (that someone else wrote) that uses
interprocess communication.
It works on strings without special characters but it fails on other
stings like "Björk".

It calls decode('utf8') but I guess the strings are not utf8 so I need
to find out what is being input.
Try this:
>>"abc".encode( "hex")
'616263'

--
HTH,
Rob
Jan 28 '07 #2
Rob Wolfe wrote:
Jammer <as****@mail.co mwrites:
>Does anyone that knows python want to write me a byte dump for strings? :-)

I am trying to modify a plugin (that someone else wrote) that uses
interprocess communication.
It works on strings without special characters but it fails on other
stings like "Björk".

It calls decode('utf8') but I guess the strings are not utf8 so I need
to find out what is being input.

Try this:
>>>"abc".encode ("hex")
'616263'
Awesome, thanks.
Jan 28 '07 #3


On Jan 29, 4:57 am, Jammer <ask...@mail.co mwrote:
Does anyone that knows python want to write me a byte dump for strings? :-)

I am trying to modify a plugin (that someone else wrote) that uses
interprocess communication.
It works on strings without special characters but it fails on other
stings like "Björk".

It calls decode('utf8') but I guess the strings are not utf8 so I need
to find out what is being input.
Try the repr() built-in function. Any byte not in printable ASCII will
be displayed in hex.

| >>foo = "\xfforick"
| >>foou = unicode(foo, 'latin1')
| >>foo8 = foou.encode('ut f8')
| >>print repr(foo), repr(foou), repr(foo8)
| '\xfforick' u'\xfforick' '\xc3\xbforick'
Jan 28 '07 #4

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

Similar topics

8
5241
by: snacktime | last post by:
Is there a module that sets the parity of a string? I have an application that needs to communicate with a host using even parity So what I need is before sending the message, convert it from space to even parity. And when I get the response I need to convert that from even to space parity. The perl module String::Parity is what I have used to do this under perl. Chris
8
4064
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had problems getting my algorithm to work and in order to help me find the solution I decided to print each line to screen as I read them. Then, to my surprise, I noticed that there was a space between every character as I outputted the lines to the...
0
6468
by: Christophe Elek | last post by:
Ok, I am completly at lost :) in both cases (my Yenc and zip utilities) i try to do the following 1) get a String 2) transform in byte 3) so some computation (either adding value to the byte or passing it to the ZipOutputStream on a ByteArrayOutputStream) 4) then transform back into String
8
4203
by: moondaddy | last post by:
I need to convert a byte array to a string and pass it as a parameter in a URL and then convert it back to the original byte array. However, its getting scrambled in the conversion. In short, here's the code: ====================================== Dim textConverter As New ASCIIEncoding Dim sParam As String = "This is my cool param" Dim bytParam() As Byte 'load the byte array here...
5
5397
by: BenG | last post by:
Hi. I have a gridview control on a web form (asp.net 2.0) that's bound to a objectDataSource. The objectdatasource which is bound to a class I've written in the DAL to read and update the database. The grid contains three columns - an ID (GUID), a name (string) and a rowversion (timestamp), and the data is passed to/from the page in an instance of a data entity object. When I open the page the grid loads properly, but if I attempt to edit...
15
4371
by: Steve | last post by:
Hi All, I have a registration code that currently has 4 bytes that are unused. I'd like to store a future date in those 4 bytes. Is there a way to convert a date to a 4 byte string? When I do something like this, string stringDate = DateTime.Parse("1/15/2210").ToBinary().ToString("X");
1
3257
by: Carmen Sei | last post by:
I have a function that read data byte and drmp to a file how can I change the string <givenname xsi:nil='true'/to <givenname>.</givenname> ====================== bool dump; std::ofstream dumpfile;
6
5283
by: Bob Altman | last post by:
Hi all, I'm looking for the fastest way to convert an array of bytes to String. I also need to convert a String back to its original Byte() representation. Convert.ToBase64String and Convert.FromBase64String seem like the closest thing I can find to what I'm looking for baked into the base class library. Can anyone suggest a better way to do this? TIA - Bob
12
13550
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} System.Text.UTF8Encoding str = new System.Text.UTF8Encoding(); string s = new string((char)107, 1); s += new string((char)62, 1);
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.