473,396 Members | 2,057 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,396 software developers and data experts.

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 1825
Jammer <as****@mail.comwrites:
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.comwrites:
>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.comwrote:
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('utf8')
| >>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
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...
8
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...
0
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...
8
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,...
5
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....
15
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...
1
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...
6
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...
12
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} ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.