Hi Chris,
I am interested in the null terminator bug you mentioned, since I have
encountered one too, not sure whether they're the same issue. When I use
the latest git source to redirect the output to file, the file cannot be
recognized as UTF-8(both by gedit and Emacs), but okay with cat, less
and direct output. I think it's due to NULL characters at the end of the
Body string, and even in the middle of it, so I made a patch to fix
this. Along with iconv for non-UCS2 Bodies.
I removed the #defines that were governing the indexes into the metadata
and just replaced all that with a metadata struct in protostructs.h.
I also fixed some endian bugs, and a null terminator bug that I didn't
notice until I piped the output through less. :-)
Thanks for this. :-)
I fixed the commit header for you. You can change your email settings
with:
git config --global user.name "Ryan Li"
git config --global user.email "r...@ryanium.com"
This sets up your ~/.gitconfig file so that all your git work will have
this set automatically.
Ryan Li
>From 8444763cc8a9b1776e63e9a030128c836c310de0 Mon Sep 17 00:00:00 2001
From: Ryan Li <r...@ryanium.com>
Date: Sat, 18 Apr 2009 23:53:59 +0800
Subject: [PATCH] Detection and removal of NULL characters inside SMS Body are now implemented, preventing from generating illegal string, iconv support
for non-UCS2 SMS Body also added.
---
src/r_sms.cc | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/r_sms.cc b/src/r_sms.cc
index 0ade0b3..ffc0cd2 100644
--- a/src/r_sms.cc
+++ b/src/r_sms.cc
@@ -159,10 +159,22 @@ const unsigned char* Sms::ParseField(const unsigned char *begin,
case SMSFC_BODY:
{
- const char *body_begin = (const char *)field->u.raw;
- Body = std::string(body_begin, body_begin + btohs(field->size));
- if (DataCodingScheme == UCS2)
+ const char *str = (const char *)field->u.raw;
+ uint16_t maxlen = btohs(field->size);
+ if (DataCodingScheme != UCS2)
{
+ for (uint16_t i = 0; i < maxlen; ++i)
+ if (str[i]) // if not null, push it
+ Body += str[i];
+ if (ic)
+ Body = ic->FromBB(Body);
+ }
+ else
+ {
+ for (uint16_t i = 0; i < maxlen; i += 2)
+ if (str[i] || str[i + 1]) // if not null, push it
+ Body += std::string(str + i, 2);
+
if (ic)
{
IConvHandle ucs2("UCS-2BE", *ic);
--
1.5.6.3
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Barry-devel mailing list
Barry-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/barry-devel