Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by StevenPongidin · Nov 01, 2012 at 07:40 AM · wwwstring

Encode String to URL friendly format

Hi.

I tried to encode a string into URL friendly format but it seems it's not working correctly.

 var username:String = "Test 123"

 var encodedUsername:String = WWW.EscapeURL(username);

 Debug.Log("Encoded username is: "+encodedUsername);  //The result is "Test+123" instead of supposedly "Test%20123"


while the other set of code I have:

 var email:String = "email@email.com"

 var encodedEmail:String = WWW.EscapeURL(email);

 Debug.Log("Encoded email is: "+encodedEmail);    //The result is "email%40email.com


Is there anything I missed? Thanks in advance.

I thought of manually using `Replace(" ","%20")` but then this won't work with other characters and I can't predict what characters will be used by the user.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by DannyB · Nov 01, 2012 at 10:29 PM

Yes, you are missing something.

There are several standards when it comes to URL encoding, each differs from the other by some mostly minor means.

One of the differences is that some standards convert space to a + and some convert space like any other illegal character to %20.

The plus sign is valid in most cases, but I found that it does not work well in some iOS related scenarios, so my workaround is to first do EscapeURL and then replace + with %20

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image StevenPongidin · Nov 02, 2012 at 03:17 AM 0
Share

Sounds good. Will this work well with other characters? Or are there any other characters that might need to be replaced as well?

avatar image DannyB · Nov 02, 2012 at 06:52 AM 0
Share

Yeah, I think that the space as a plus sign is the only significant difference for our case.

avatar image StevenPongidin · Nov 02, 2012 at 07:00 AM 0
Share

Okay, thanks for the workaround. =)

avatar image
4

Answer by MuYouGe · Aug 26, 2016 at 12:20 PM

Best answers is here

Have you tried System.Uri.EscapeUriString()?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image codenameglassy · Apr 03 at 10:25 AM 0
Share

how exactly can i implement this?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WWW & and strings in C# 1 Answer

Maximum WWW.text fetch size 1 Answer

Display Movie Name From www Address With A UI Text? 0 Answers

WWW object has doesnt return the full string 2 Answers

If Statement Acting Strange 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges