Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
No whitespaces in string, what have I done wrong?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
idleman  
View profile  
 More options May 1 2012, 8:47 pm
From: idleman <evoo...@gmail.com>
Date: Tue, 1 May 2012 17:47:52 -0700 (PDT)
Local: Tues, May 1 2012 8:47 pm
Subject: No whitespaces in string, what have I done wrong?

Why does all white spaces get removed in the example below?

//C++
Handle<Value> System::log(const Arguments& args)
{
    for(int i = 0, s = args.Length(); i < s; ++i) {
       String::AsciiValue ascii(args[i]);
        os.write(*ascii, ascii.length()) << std::endl; //os = std::ostream&
object
    }
    return Undefined();

}

//Then in javascript, there the System object have been "exposed" to
JavaScript.
System.log("How are you?");  //prints "howareyou?" not "how are you?", e.g
no whitespaces

In the example do I get the text: "Howareyou?", not "How are you?", what
does I wrong? Why are all white spaces removed? The std::ostream::write
write oformatted output, so it does not remove any white space, so it is
not the problem.

Thanks in advance!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mdcb808  
View profile  
 More options May 1 2012, 9:22 pm
From: mdcb808 <mdcb...@gmail.com>
Date: Tue, 01 May 2012 18:22:22 -0700
Local: Tues, May 1 2012 9:22 pm
Subject: Re: [v8-users] No whitespaces in string, what have I done wrong?

what happens if you replace your "// os = std::ostream& object" with
say, std::cerr? same code snippet for me, doesn't strip any white space:

for(int i = 0, s = args.Length(); i < s; ++i) {
   v8::String::AsciiValue ascii(args[i]);
   std::cerr.write(*ascii, ascii.length()) << std::endl;

}

On 05/01/12 17:47, idleman wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile  
 More options May 2 2012, 3:06 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Wed, 2 May 2012 09:06:16 +0200
Local: Wed, May 2 2012 3:06 am
Subject: Re: [v8-users] No whitespaces in string, what have I done wrong?

Google for std::iosteam skipws.

----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
On May 2, 2012 2:47 AM, "idleman" <evoo...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
idleman  
View profile  
 More options May 2 2012, 5:42 am
From: idleman <evoo...@gmail.com>
Date: Wed, 2 May 2012 02:42:56 -0700 (PDT)
Local: Wed, May 2 2012 5:42 am
Subject: Re: No whitespaces in string, what have I done wrong?

Well, like a said before, the std::ostream object is not the problem, if i
change the method to:

v8::Handle<v8::Value> System::log(const v8::Arguments& args)
{
    for(int i = 0, s = args.Length(); i < s; ++i) {
        v8::String::AsciiValue ascii(args[i]);
        std::cerr << "Length: " << ascii.length() << std::endl;
        std::cerr.write(*ascii,ascii.length()) << std::endl;
    }
    return v8::Undefined();

}

Will it print out the length without any whitespaces, e.g javascript code:
System.log("      "); prints "Length: 0". However, do anyone have any idea
what I can have done wrong? I am adding the method by doing something like
the following, if it helps:

Handlescope handle_scope;
Persistent<Context> context = context(Context::New());
Context::Scope context_scope(context);
Local<ObjectTemplate> env = ObjectTemplate::New();
env->Set(String::New("log"), FunctionTemplate::New(&System::log));
//System.log is a static method of course
context->Global()->Set(String::New("System"), env->NewInstance());

Den onsdagen den 2:e maj 2012 kl. 02:47:52 UTC+2 skrev idleman:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakob Kummerow  
View profile  
 More options May 2 2012, 6:00 am
From: Jakob Kummerow <jkumme...@chromium.org>
Date: Wed, 2 May 2012 12:00:49 +0200
Local: Wed, May 2 2012 6:00 am
Subject: Re: [v8-users] Re: No whitespaces in string, what have I done wrong?

I haven't checked where that logic lives, but I guess the string you're
passing is automatically split up into several arguments along whitespace
boundaries. Try printing the value of args.Length() to verify this.
If things behave like command shells, you should be able to do
System.log("\"multi word argument\""); to get a single argument consisting
of several words.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile  
 More options May 2 2012, 9:09 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Wed, 2 May 2012 15:09:21 +0200
Local: Wed, May 2 2012 9:09 am
Subject: Re: [v8-users] Re: No whitespaces in string, what have I done wrong?

The problem is formatted vs non-formatted output.  Write()  does
unformatted. Stream operators use formatted i/o *by* default.

----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
On May 2, 2012 11:42 AM, "idleman" <evoo...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
idleman  
View profile  
 More options May 2 2012, 12:53 pm
From: idleman <evoo...@gmail.com>
Date: Wed, 2 May 2012 09:53:51 -0700 (PDT)
Local: Wed, May 2 2012 12:53 pm
Subject: Re: No whitespaces in string, what have I done wrong?

Now was it embarrassing, but I forgot that std::istream_iterator skip white
spaces by default, which I used to read the JavaScript file, so no white
spaces was not even compiled, but I assume it can happen all, thanks anyway!

Cheers


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »