Results 1 to 4 of 4

Thread: Cannot send strings with embedded \0

  1. #1
    blair is offline Registered User
    Name: Blair Zajac
    Organization: Sony Pictures Imageworks
    Project: VnP
    Join Date
    Mar 2007
    Posts
    34

    Cannot send strings with embedded \0

    I accidentally got a \0 into a Java string used as an exception error message sent to the client and the any part of the string after the \0 does not appear on the client.

    Using IcePy 3.2.0 for the client and server, you can reproduce this pretty easily:

    Code:
        interface Test
        {
            idempotent string
            getString();
        };
    Server side code:

    Code:
    class TestI(Test):
        def getString(self, current=None):
            s = 'hello '
            for i in range(3):
                s += chr(0)
            s += ' there'
            return s
    Client side code:

    Code:
            s = self.VnpClock.getString()
            print repr(s)
    I get the string 'hello '. If you change the chr(0) to a chr(1) then it works.

    I was able to get the chr(0) into the Java server in the first place by passing from Python code to the Java server a string with a \0 in it.

    Regards,
    Blair

  2. #2
    Andreas Scherer is offline Registered User
    Name: Andreas Scherer
    Organization: Private Linux Site
    Project: Evaluating Ice-C++, Ice-Java, Ice-Python, Ice-Ruby
    Join Date
    Mar 2005
    Location
    Berlin, Germany
    Posts
    50
    Probably you are refering to the situation mentioned in section 4.8.3 of the Ice manual (page 91/109 of the 3.2.0 pdf):
    Slice strings use the Unicode character set. The only character that cannot appear inside a string is the zero character.
    Take care,
    Andreas

  3. #3
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Andreas is correct, 0 is not allowed in Slice strings. See this footnote. However, it is a bug that Ice does not raise an exception. Thanks for reporting this, we will investigate and fix this.

  4. #4
    blair is offline Registered User
    Name: Blair Zajac
    Organization: Sony Pictures Imageworks
    Project: VnP
    Join Date
    Mar 2007
    Posts
    34
    Thanks. It would be nice to get an exception on attempting to put a \0 into a string.

    Regards,
    Blair

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Efficiency with very long strings
    By myrosia in forum Help Center
    Replies: 1
    Last Post: 10-22-2009, 11:17 AM
  2. Embedded Ice
    By Banjo in forum Help Center
    Replies: 2
    Last Post: 10-07-2009, 06:24 PM
  3. win32/ question on passing and returning strings
    By stephan in forum Help Center
    Replies: 2
    Last Post: 01-04-2004, 02:49 PM
  4. Method tokens: strings vs. indices
    By JohnBates in forum Comments
    Replies: 1
    Last Post: 05-06-2003, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •