473,854 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting a unicode byte array into a ASCII-string

Hey,

I'm currently working on a project to get GPS-data onto a PDA. At this
stage, I'm already getting data from the device, but my problem is: It's
rubbish. At least, it looks as if it were rubbish.

example: "`?~?\0?~?~??? ?\0x?x?x?x?x?x~ ??x?x?xx?\0x?x? "

I found patterns in the code I received, so it's just encoded.

I download information byte-by-byte from the device, and store it in a
byte[] array. Because the GPS-device is made in Taiwan, the tokens are
in unicode (16-bit). The standard I'm want to use is ASCII.

Does anybody have an idea how I could translate the Unicode Byte Array
into a ASCII string ?

Thanks in advance for any assistance!

Greetz,

Luk Vloemans
IT Student

Nov 15 '05 #1
4 2289
Luk Vloemans <lu**********@s tudent.luc.ac.b e> wrote:

<snip>
Does anybody have an idea how I could translate the Unicode Byte Array
into a ASCII string ?


See my message to your similar post a few hours ago. If that doesn't
help, please give more details.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2
Hey,

I'm sorry I didn't notice your earlier response.
I tried what you said, but the end-result consists completely of
question-marks.

Perhaps I was wrong about the unicode, but I can't think of any other
explenation..

thanks anyhow for your response!

Luk
Luk Vloemans <lu**********@s tudent.luc.ac.b e> wrote:

<snip>
Does anybody have an idea how I could translate the Unicode Byte Array
into a ASCII string ?

See my message to your similar post a few hours ago. If that doesn't
help, please give more details.


Nov 15 '05 #3
Luk Vloemans <lu**********@s tudent.luc.ac.b e> wrote:
I'm sorry I didn't notice your earlier response.
I tried what you said, but the end-result consists completely of
question-marks.

Perhaps I was wrong about the unicode, but I can't think of any other
explenation..


Perhaps it's unicode with the other byte order?

If you could post some example byte sequences and the characters you
expected to get out, we could try to figure it out.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #4
Luk Vloemans <lu**********@s tudent.luc.ac.b e> wrote:
Okay, I'll give a few examples, but I'm afraid that what I post here, is
already (wrongly) converted to ASCII.


Hmm... that's not likely to help much, I'm afraid - can't you get it in
the raw byte array form, and post that? The trouble is that the
question marks could be anything...

What's somwhat straight is that two lines which *should* start with the
same data ($GP) don't start with the same bytes by the looks of it
(assuming the three examples you gave are meant to be the three lines
of text you posted). I don't suppose it's compressed or something like
that is it? What's the documentation for this like?

<snip>

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #5

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

Similar topics

12
10714
by: Peter Wilkinson | last post by:
Hello tlistmembers, I am using the encoding function to convert unicode to ascii. At one point this code was working just fine, however, now it has broken. I am reading a text file that has is in unicode (I am unsure of which flavour or bit depth). as I read in the file one line at a time (readlines()) it converts to ascii. Simple enough. At the same time I am copressing to bz2 with the bz2 module but that works just fine. The code...
22
5523
by: Keith MacDonald | last post by:
Hello, Is there a portable (at least for VC.Net and g++) method to convert text between wchar_t and char, using the standard library? I may have missed something obvious, but the section on codecvt, in Josuttis' "The Standard C++ Library", did not help, and I'm still awaiting delivery of Langer's "Standard C++ IOStreams and Locales". Thanks,
4
2468
by: Majed | last post by:
Hi , all I'm trying to write unicode to a file for another app (not developed with vs2003) to read it. I used StreamWriter with unicode encoding.but I was surprised that the streamwriter adds FFFE to the start of the file,which stopes the other app from reading it!! any idea how to stope it frome doing that,do I have to use another class #####writer that supports unicode? help me Please! Thanks
11
3678
by: Patrick Van Esch | last post by:
Hello, I have the following problem of principle: in writing HTML pages containing ancient greek, there are two possibilities: one is to write the unicode characters directly (encoded as two bytes) into the HTML source, and save this source not as an ASCII text, but as a UNICODE text file (using 16 bits per character, also for the Western ASCII characters, which are usually encoded as Ox00XX with XX the ASCII code) ; or to write a pure...
0
1248
by: Luk Vloemans | last post by:
Hi, I've got a Byte consisting of Unicode characters. (16bit) Is there an easy function to convert this Byte into an ASCII format ? Thanks for any assistance. Luk Vloemans IT Student
8
25652
by: Mark Relly | last post by:
Hello, I was wondering if anybody knew much about Unicode strings in C#. I have a Unicode encoded string but how can I see the contents of this string so it doesn't display "???????????"? I don't want to trans form it back into a ASCII string using Encoding.ASCII before I view the data its the Unicode data I wish to view.
24
9084
by: ChaosKCW | last post by:
Hi I am reading from an oracle database using cx_Oracle. I am writing to a SQLite database using apsw. The oracle database is returning utf-8 characters for euopean item names, ie special charcaters from an ASCII perspective. I get the following error: > SQLiteCur.execute(sql, row)
14
6438
by: abhi147 | last post by:
Hi , I want to convert an array of bytes like : {79,104,-37,-66,24,123,30,-26,-99,-8,80,-38,19,14,-127,-3} into Unicode character with ISO-8859-1 standard. Can anyone help me .. how should I go about doing it ? Thanks
7
2512
by: JTree | last post by:
Hi,all I encountered a problem when using unicode() function to fetch a webpage, I don't know why this happenned. My codes and error messages are: Code: #!/usr/bin/python #Filename: test.py #Modified: 2006-12-31
13
5081
by: George Sakkis | last post by:
It seems xml.etree.cElementTree.iterparse() is not unicode aware: .... print elem.text .... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 64, in __iter__ UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-15: ordinal not in range(128)
0
9899
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
11024
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10740
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10362
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9510
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
7076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5738
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
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
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

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.