On Wed, Mar 27, 2013 at 7:41 AM, Don Dwiggins <[email protected]>wrote:
> On 3/17/13 9:20 PM, Don Dwiggins wrote:
>
> I'm developing a small pyjs application, which gets data from a URL and allows
> displaying it in various ways. The application uses
> HTTPRequest().asyncGet in the main section, and does most of its processing
> in the onCompletion handler. It works beautifully using pyjd, however...
>
> I've started using Firebug to get a clearer picture of what's going on. The
> request completes, and the onCompletion method is called; so far, so good.
>
> The data that I'm getting in the request is a Unicode representation of a csv
> file. I have the line:
>
> csvlines = csvdata.encode('utf-8').split('\n')
>
> to convert the string to utf-8 and turn it into a list of lines. The
> error I get in the JS is:
>
> TypeError: csvdata.encode is not a function
> return csvdata['encode']('utf-8');
>
> At this point, I'm not sure how to proceed. Does this mean that pyjs
> doesn't have the equivalent of a string method called "encode"? Or is
> there something else going on? If the former, is there an alternate way
> to accomplish what I'm trying to do?
>
You're right. The pyjs string has not the encode/decode method. The pyjs
string is based on the javascript string (read: it is the javascript string
with some extra methods). The encode/decode methods are not implemented. We
could maybe implement some dummy methods (just returning 'self').
Javascript strings are always unicode (if I recall correctly).
If you're doing it right (correct paths etc.), you'll be using the csv
module for pyjs as found in pyjs/src/pyjs/lib/
--
---
You received this message because you are subscribed to the Google Groups
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.