All functions str* doesn't work well with multi-bytes strings (such as
UTF-8)

Regards,

Nicolas

Le mardi 21 avril 2009 à 17:29 +0800, Ryan Li a écrit :
> Hi Chris,
> 
> I gave a look at the strnlen() function, and found that it wouldn't work 
> as I hoped. Since a simple test of strlen("\x40\x00\x40", 4) will give 
> the return value 1. This simply doesn't work for the strings that have 
> NULL characters *in the middle*. However, as I can see from the raw SMS 
> data, there's an instance encoded in 7-byte, having a NULL in the 
> middle. Maybe the service center lost the data and used NULL as a 
> replacement. Hence I think the for() loops are necessary.
> Incidentally, I wanted to use the ParseFieldString() function in 
> record.cc at the first time, but didn't work. However, I think it'd be 
> prettier if we replace the for() loop inside the function with an 
> equivalent strnlen(). Moreover, or could we just implement the for() 
> loop detecting NULLs-in-the-middle inside the ParseFieldString() function?
> 
> Chris Frey wrote:
> > I used the strnlen() function.  See the latest commit in the git tree
> > with 'git log -p'
> >
> > With UCS2 strings, maybe a function like wcsnlen would work for us.
> > I'd rather not add for() loops to various parts of the code, if we can
> > use strnlen() and wcsnlen(), so I haven't applied your patch.
> 
> Ryan Li
> 
> ------------------------------------------------------------------------------
> 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

-- 
Nicolas VIVIEN


------------------------------------------------------------------------------
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

Reply via email to