import StringIO

class KQMLString(object):
    def __init__(self, data=None):
        if data is None:
            self.data = ''
        else:
            self.data = data

    def length(self):
        return len(self.data)

    def char_at(self, n):
        return self.data[n]

    def equals(self, obj):
        if not isinstance(obj, KQMLString):
            return False
        else:
            return obj.data == self.data
    
    # TODO: make sure that the double quotes are printed correctly
    def write(self, out):
        data_str = out.write(self.data)

    def to_string(self):
        out = StringIO.StringIO()
        self.write(out)

    def string_value(self):
        return self.data

@@ -430,124 +430,192 @@
 ata%0A
+%0A
     
-%0A    # TODO: make sure that the double quotes are printed correctly%0A    def write(self, out):%0A        data_str =
+def write(self, out):%0A        out.write('%22')%0A        for ch in self.data:%0A            if ch == '%22' or ch == '%5C%5C':%0A                out.write('%5C%5C')%0A            out.write(ch)%0A       
  out
@@ -621,25 +621,19 @@
 t.write(
-self.data
+'%22'
 )%0A%0A    d
@@ -709,16 +709,46 @@
 ite(out)
+%0A        return out.getvalue()
 %0A%0A    de
@@ -786,16 +786,127 @@
 eturn self.data%0A
+%0A    def __str__(self):%0A        return self.to_string()%0A%0A    def __repr__(self):%0A        return self.__str__()%0A

Fix KQMLString writing