472,803 Members | 979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,803 software developers and data experts.

Encoding conversions

I have an unmanaged dll that decrypts some encrypted text read out of a 2D
Barcode

This decryption function fails gracefully with a message that it could not
get the decoded string. the string is partially decoded but looks like it has
droped out half way through after ecountering an illegal character or
something. I also have a third party standalone app written in C++ that
decrypts the barcode successfully using all the same versions of dlls etc I
am using in .net. I am tryinig to unwrap this app and incorporate the
functionality in a more managed way into my systems (With the software
vendors permision) .

I have spoken to the software vendor and they have suggested that there may
be a problem with the unicode string that I am passing in and the array of
unsigned characters that the native C++ app passes in.

My API definition and call look like this

Private Declare Function ARCED_decode Lib "DecoderCD.dll" Alias
"_ARCED_decode@28" _
(ByVal encodeString As StringBuilder, ByVal mailerID As
StringBuilder, _
ByVal mailerRef As StringBuilder, ByVal decodeString As
StringBuilder, _
ByRef pMailerRefLen As Integer, ByVal maxSize As Integer, _
ByVal errStr As StringBuilder) As Integer

Sub Main()
Dim _encodeBuf As New StringBuilder(255)
Dim _decodeBuf As New StringBuilder(255)
Dim _decodebufLen As Integer
Dim _mailerRefBuf As New StringBuilder(255)
Dim _mailerRefBufLen As Integer
Dim _mailerIDbuf As New StringBuilder(10)
Dim _errorBuf As New StringBuilder(255)

_encodeBuf.Append(ReadBarcode)

_decodebufLen = ARCED_decode(_encodeBuf, _mailerIDbuf,
_mailerRefBuf, _decodeBuf, _mailerRefBufLen, _encodeBuf.Capacity + 1,
_errorBuf)
End Sub

I have attemped to convert from unicode bytes to an array of bytes of
various encodings filling my string builders with these like this

Public Function ConvertToUTF8(ByVal EncodeString As String) As StringBuilder
Dim _UTF8Encoding As New UTF8Encoding
Dim _UnicodeEncoding As New UnicodeEncoding
Dim _UnicodeBytes() As Byte = _UnicodeEncoding.GetBytes(EncodeString)
Dim _UTF8Bytes() As Byte =
_UnicodeEncoding.Convert(_UnicodeEncoding, _UTF8Encoding, _UTF8Bytes)

Dim _sb as New Stringbuilder(255)
For each UTF8Byte As Byte in _UTF8Bytes
_sb.Append(UTF88yte)
Next

Return _sb

End Function

Below is a C++ code snippet from a sample sent to me by the software vendor
of how their app builds up its char array
unsigned char encodeBuf[256];
int encodeBufLen = bars[i]->DataString->Length;
for (int j = 0; j < encodeBufLen; j++)
{
encodeBuf[j] = (unsigned char)bars[i]->DataString->get_Chars(j);
// printf ("%d ", encodeBuf[j]);
}

I cannot work out
a) what encoding is equivilent to the Unsigned Char (although I suspect UTF8)
b) whether I have done th job properly (obviously not 'cos it don't work)
c) if i am barking up the wrong tree and there is some other problem.

Any suggestion greatly appreciated
Cheers
Ben

Aug 11 '05 #1
0 984

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

Similar topics

5
by: Edward K. Ream | last post by:
Am I reading pep 277 correctly? On Windows NT/XP, should filenames always be converted to Unicode using the mbcs encoding? For example, myFile = unicode(__file__, "mbcs", "strict") This...
14
by: Sebastian Meyer | last post by:
Hi newsgroup, i am trying to replace german special characters in strings like str = re.sub('', 'oe', str) When i work with this, i always get the message UniCode Error: ASCII decoding error...
7
by: Erik Bethke | last post by:
Hello All, I have found much help in the google archives but I am still stuck... here is my code snippet: path = os.getcwd() path = path.decode('UTF8') Now the trouble is I am getting that...
4
by: Viorel | last post by:
For me is a little bit mysterious how work encoding and decoding functions, what is underneath of their calling? Encoding1.GetBytes(string1); in particularly ASCII.GetBytes(string1) ...
10
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6...
0
by: joseph speigle | last post by:
hi, To see the query results in native language see http://database.sarang.net/?inc=read&aid=5368&criteria=pgsql&subcrit=qna&id=&limit=20&keyword=&page=1 the simpler url is ...
4
by: Christina | last post by:
Hey Guys, Currently, I am using the below code: Dim oReqDoc as XmlDocument Dim requiredBytes As Byte() requiredBytes = System.Text.UTF8Encoding.UTF8.GetBytes(oReqDoc.InnerXml). Here, I am...
5
by: Licheng Fang | last post by:
I want to store Chinese in Unicode internally in my program, and give output in UTF-8 or GBK format. After two days of searching and reading, I still cannot find a simple and straightforward way to...
2
by: joakim.hove | last post by:
Hello, I am having great problems writing norwegian characters to file from a python application. My (simplified) scenario is as follows: 1. I have a web form where the user can enter his...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.