[sosi2osm] 09/30: Convert the entire line to utf-8 before we parse it

Ruben Undheim rubund-guest at moszumanska.debian.org
Sat Oct 4 13:07:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch upstream
in repository sosi2osm.

commit 1958d616ef0e803e611b9edc182d87a683a60ebb
Author: Knut Karevoll <gnonthgol at gmail.com>
Date:   Tue Oct 8 22:14:11 2013 +0200

    Convert the entire line to utf-8 before we parse it
---
 tag.cpp | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tag.cpp b/tag.cpp
index 08c6383..4edc975 100644
--- a/tag.cpp
+++ b/tag.cpp
@@ -9,6 +9,9 @@ void setEncoding(char* encoding) {
 }
 
 char* toUTF8(char* in, char* outBuf, size_t outlen) {
+    if (in == NULL) {
+        return NULL;
+    }
     size_t inlen = strlen(in)+1;
     char* out = outBuf;
     
@@ -26,7 +29,8 @@ char* toUTF8(char* in, char* outBuf, size_t outlen) {
 void outputTags() {
     long lines = getSOSILinesLength();
     for (int i = 1; i < lines; i++) {
-        char* key = getSOSILine(i);
+        char buffer[256];
+        char* key = toUTF8(getSOSILine(i), buffer, 256);
         if (key != NULL) {
             while (key[0] == '.') key++;
             
@@ -39,12 +43,7 @@ void outputTags() {
                 while (last[-1] == '"') last--;
                 *last = '\0';
                 
-                char keyBuf[256];
-                char valueBuf[256];
-                
-                printf("<tag k=\"%s\" v=\"%s\"/>\n",
-                    toUTF8(key, keyBuf, 256),
-                    toUTF8(value, valueBuf, 256));
+                printf("<tag k=\"%s\" v=\"%s\"/>", key, value);
             }
         }
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/sosi2osm.git



More information about the Pkg-grass-devel mailing list