473,395 Members | 1,502 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,395 software developers and data experts.

Pyasn1 decoding with OS Specific carriage return --' \r\n'

I'm handling BER encoded Call Data Records (CDR). from GPRS Tunneling protocol. In which I got one field's value with `'\r\n'` in it.

`'\xa0\x06\x80\x04\r\n\xc4\x086'` -- This is the encoded string or `bytearray` which causing the issue. It has all the TLV information required for the tag [b]a0, and its length is 06. There is an inner tag 80 and its length is 04. But if we take the output in the following way it prints like this.

The inner tag 80's value causing the issue. Its length is 04 but when we decode it with `pyasn1` the length became 05 since it counts `\r` and `\n` separately. I think the encoder which encodes this data assumes that `\r\n` is a single element. But while decoding this using pyasn1 it throwing an error due to this missing length on the TLV representation of encoded value.

map(ord, '\xa0\x06\x80\x04\r\n\xc4\x086')
[160, 6, 128, 4, 13, 10, 196, 8, 54]

We are using implicit tag numbers.

Is there any way to solve this using pyasn1's ber decoder and encoder.


Thanks and Regards,

Haridas N.
Feb 4 '13 #1
1 1887
bvdet
2,851 Expert Mod 2GB
I don't know anything about pyasn1 or the data you are describing. If you could strip out the '\r', would that help with your issue?
Expand|Select|Wrap|Line Numbers
  1. >>> "".join('\xa0\x06\x80\x04\r\n\xc4\x086'.split("\r"))
  2. '\xa0\x06\x80\x04\n\xc4\x086'
  3. >>> "".join([chr(n) for n in map(ord, '\xa0\x06\x80\x04\r\n\xc4\x086') if n != 13])
  4. '\xa0\x06\x80\x04\n\xc4\x086'
  5. >>> 
Feb 7 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Canes_Rock | last post by:
The information posted at: ...
5
by: Pia | last post by:
Please help! I'm trying to get my xsl to produce 0x0D, not just 0x0A. Any ideas on how to do this? Right now, if I try the following, my output only shows 0x0a: <xsl:variable name="cr"...
2
by: Andrew Chanter | last post by:
I have a VBA function that returns a string including "vbcr" (VB Carriage Return) to seperate a list into multiple rows, eg Item1 & vbcr & Item2 & vbcr & Item3 This works as planned in the...
1
by: chrissmith_76_Fed_Up_With_Spam | last post by:
Hello all, I am using Access 2002, with file format of Access 2000, and am experiencing a problem. I have a subform that is shown in datasheet view for users to edit data direct to a table. ...
2
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
3
by: Simon Middlemiss | last post by:
I have a multiline textbox which I would like populated in the following manner. "Line1 Line2 Line3 Line4" etc. I know how to do it in code, but is there a way to do it in the design view?
2
by: David Cho | last post by:
I am using this expression \d+(,\s*\d+)* to allow only numbers and commas. But if there are carriage returns mixed, it is not validated. Is tehre a way to ignore all carriage returns? I...
3
by: Dinsdale | last post by:
I have an xml file that is read into an object using serialization. One of the objects has a string field called delimeter that I want to contain a carriage return. Instead of trying to include the...
11
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
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...

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.