Re: Octstr support for converting to and from HTML 4 entities.

Rene Kluwen / Chimit Software Solutions <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hello Oded,

Ouch! Did you test this?
For me, the from-conversion does not work at all! I get garbage after
trying to convert a string with entities in it.
Actually, your code is correct. But according to my (CVS) version,
there is a terrible bug in octstr_insert_char() in octstr.c.

Attached is my patch to fix it.

-- Rene...

Sunday, September 22, 2002, 8:09:01 PM, you wrote:

OA> Hi list.

OA> We needed the ability to encode data to XML/HTML with HTML 4 entities as defined by W3C, so I thought that adding it to the Octstr infrastructure would be nice - so that other people will be able
OA> to use it.

OA> So here it is for your review - don't spare the ammo.

OA> Both conversions (to HTML entities and from) are using a .def file that is included into the code. the 'to' coversion is very straight forward and should be very easy. I'm afraid that the 'from'
OA> conversion is rather processor intensive - I'm yet unsure as to how to make it more efficient and still keep it as readable.

OA> --
OA> Oded Arbel
OA> m-Wise mobile solutions
OA> [email protected]

OA> +972-9-9581711 (116)
OA> +972-67-340014

OA> ::..
OA> Finagle's laws for existentialists -
OA> 8.Everything takes longer than you think
 



-- 
Best regards,
 Rene                            mailto:[email protected]
ostr_insert_char.patch (application/octet-stream, 614 B)
Index: gwlib/octstr.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/octstr.c,v
retrieving revision 1.137
diff -u -r1.137 octstr.c
--- gwlib/octstr.c	4 Sep 2002 09:13:11 -0000	1.137
+++ gwlib/octstr.c	22 Sep 2002 21:23:10 -0000
@@ -1220,7 +1220,7 @@
     
     octstr_grow(ostr, ostr->len + 1);
     if (ostr->len > pos)
-        memmove(ostr->data + 1, ostr->data + pos, ostr->len - pos);
+        memmove(ostr->data + pos + 1, ostr->data + pos, ostr->len - pos);
     memcpy(ostr->data + pos, &c, 1);
     ostr->len += 1;
     ostr->data[ostr->len] = '\0';
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.