login about faq

This is what I am getting. I imagine it's a charset issue, but I've tried every combo of VariantToString I can think of in this manner... VariantToString(result,"UTF-8")


Any suggestions how to convert it?

asked Jan 21 '13 at 05:14

jamesblake's gravatar image


What language are you using? Can you show more of your code? What datatype is "result" (a byte array, string, etc...)? Does the language you are using use Unicode strings? I don't think we have enough information to solve the problem.

(Jan 23 '13 at 11:27) jpbro ♦

I'm using it in Director. This is using the Upload Object

upload.Path="/pathToAPI.json" upload.AddFileReference ("image",pathToImage) upload.AddParam("key","APIKEY") upload.HostName = "http://api.hostname.com" upload.port = 80 upload.ssl = 0 upload.BeginUpload() result=upload.ResponseBody

What's interesting is that when using the HTTP Object it works fine

req.UseUpload() req.Path="/pathToAPI.json" req.AddFileForUpload("image",pathToImage) req.AddParam("key","APIKEY") domain = "http://api.hostname.com" port = 80 ssl = 0 resp= http.SynchronousRequest(domain,port,ssl,req) result=resp.BodyStr

(Jan 23 '13 at 13:31) jamesblake

The problem is that the httprequest object isn't asynchronous, so my program hangs during the upload, hence the need to use the Upload object.

There are no datatypes for the results. The http object one just displays the json result as normal text and the upload object one displays it with the ????

(Jan 23 '13 at 13:32) jamesblake

You can do asynchronous communications using the HTTP component by setting the UseBgThread property to 1, and then test against the various Bg* properties. Since the HTTP component produces the results you are expecting, then maybe this approach is worth a try?

(Jan 23 '13 at 14:18) jpbro ♦

Also, one thing that's not clear - are you assigning the return value of VariantToString() to a string variable?

In your first chunk of code it looks like you are just calling VariantToString(result, "UTF-8") without assigning it to anything. If you are just calling VariantToString on the result data, then the value of result will not be changed.

Your second piece of example code doesn't show your VariantToString call, so I'm unclear as to how you are using it.

(Jan 23 '13 at 14:40) jpbro ♦

I will try the UseBGThread, thanks, I didn't know abut that.

I was doing something like result = VariantToString(upload.ResponseBody, "UTF-8")... with no success. is that the right character encoding to try?

(Jan 23 '13 at 14:48) jamesblake

UseBGThread works, so I will use that. If you see something wrong with my variantToString code, let me know, otherwise I'm all set. Thanks.

(Jan 23 '13 at 15:11) jamesblake

To be honest, I'm not sure what's wrong with the VariantToString() call. Assuming that:

A) result is a unicode string variable type, B) the response body is in UTF-8 encoding, C) that you actually called upload.VariantToString and not just VariantToString

then I think it should have worked. I don't actually use the Upload component though, so I'm not the best person to ask.

(Jan 23 '13 at 15:36) jpbro ♦
showing 5 of 8 show all

I would recommend brushing up on some required concepts first. Start here:


and then sequence through the tutorial by clicking the "Next: ..." link at the end of the text on each page. Study the information on each page. The last web page in the tutorial may answer your question.


answered Jan 21 '13 at 10:02

chilkat's gravatar image

chilkat ♦♦

I'm not using VB (or any of the other major languages). I tried VariantToString(res,"Windows-1252") with the same result. Can I even use VariantToString for this?

(Jan 21 '13 at 13:30) jamesblake

Been all through that tutorial and still unsure how to convert the returned text. Can VariantToString be used or not?

(Jan 22 '13 at 23:47) jamesblake
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jan 21 '13 at 05:14

Seen: 743 times

Last updated: Jan 23 '13 at 15:36

powered by OSQA