Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by will108 · Dec 15, 2013 at 01:05 AM · wwwchatmessages

Decode message from internet

Hi, Im making an app where users can send each other messages sent through specific templates and themes. I am having them sent as numbers and letters representative of the theme and message. For example, if the user choses theme a, and the message is "hey", then the thing sent and received by the phone would be: a_hey How can I have the phone understand "a_hey" and put it into variables such as: var theme = a, and text = "hey" Thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by YoungDeveloper · Dec 15, 2013 at 01:29 AM

If you want to write that "a" in string itself, then the only way to later "decode" it, is to process that string by single char, and only then post it.

Instead of using just "a" or "b" as first special characters, I suggest using something more readable and rarer, it will save up couple if checks and some code launching on decoding. Lets assume our first special symbol is % and second is the number of template that must be used. For example %2Hey

 string messageThatMustBeDecoded = "%1Hey there, how are you doing?"
 int templateNumberToUse;
 
 string cleanMessage = "";
 
 void ProcessString(messageThatMustBeDecoded){
 
     for(int i = 0; i < messageThatMustBeDecoded.Length; i++) //Loops through number, which are in the string array element size
         if(messageThatMustBeDecoded[i] == '%'){//special symbol found
             if(i < messageThatMustBeDecoded.Length-1){ //if its not the end of the string
                  templateNumberToUse = int.Parse(messageThatMustBeDecoded[i+1]); //parse next element after % (that is number) to int
 
                 //So now you pretty much know the template number/index, all we need now is the clean string itself!
 
                 i += 2; //We move i where text starts
                 for(int a = i; a < messageThatMustBeDecoded.Length; a++){ //we go through all remaining text
                     cleanMessage += messageThatMustBeDecoded[a];
                 }
                 return; //function ends!
             }
         }
     }

 }

Now "templateNumberToUse" contains the number for template

But "cleanMessage" contains "Hey there, how are you doing?"

The solution will be different for you, because i cant know what exactly you want, but this is very similar and will get you the idea!

Comment
Add comment · 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

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

17 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

global chat 0 Answers

Screenshot PNG to GUITexture (NONE Texture) 0 Answers

Remove .dll 1 Answer

WWWForm.Addfield not able to post data to server 1 Answer

www.text + php + c# issue 2 Answers


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