[Closed] How to URLEncode in maxscript?
Hi!
Is there a way to URLEncode with MaxScript ? Maybe with a DotNetObject? Or Class?
I need your help!
Thanks,
OZRay
You can use .net’s HttpUtility.UrlEncode method.
http://stackoverflow.com/questions/575440/url-encoding-using-c
Hehehe I know that it’s possible with .NET but can’t figure out how to do it in maxscript hehehe !!
Regards,
OZRay
Well I suppose you can do something like this:
(
local httpUtility = dotnetClass "System.Web.HttpUtility"
local urlEncodedString = httpUtility.UrlEncode "theStringToEncode"
)
Thanks, I already tested this but the problem is any class that I try result in undefined…
I can’t make it work…
encodeClass = dotnetClass “System.Web.HttpUtility”
encodeClass = dotnetClass “System.Web.HttpUtility.UrlEncode”
encodeClass = dotnetClass “System.Web”
Anything give me a undefined…
You know why?
Regards,
OZRay
try loading the System.Web assembly first. It’s probably not loaded by default with max or something like that.
dotnet.loadAssembly "System.Web"
It’s probably caused by what Gravey mentioned, but just a small note: Of your three examples, only the first one is actually correct. The second is a method in the class HttpUtility, the third is a namespace.
It’s working, for complete reference this is my function.
fn f_URLEncode _STR =
(
dotnet.loadassembly “System.Web”
local httpUtility = dotnetClass “System.Web.HttpUtility”
local urlEncodedString = httpUtility.UrlEncode _STR
return urlEncodedString
)
f_URLEncode “This! Is my %# URL *() Encode@@@”
return this: This!+Is+my+%25%23+URL+*()+Encode%40%40%40
Regards,
OZray