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
-1
Question by tanuj0092 · May 26, 2014 at 11:22 AM · serverstringcharacterslanguageencoding

How can I convert UTF8 string to arabic?

Actually my game contains arabic language. I get the string "\u0639\u0632\u0648\u0632 \u0627\u0646\u062f\u062c\u0627\u0646\u064a" from server. I need to convert it into arabic. I am using this code:

 byte[] _data = System.Text.Encoding.ASCII.GetBytes( Target );
 string _temp = System.Text.Encoding.UTF8.GetString ( _data );
 byte[] _data1 = System.Text.Encoding.UTF8.GetBytes ( _temp );
 return System.Text.Encoding.ASCII.GetString ( _data1 );

where target is the string received from server. Please help!!!

Comment
Add comment · Show 2
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 Multiaki · Dec 06, 2015 at 04:05 AM 0
Share

Could you solve the problem?

avatar image kidmosey · Dec 06, 2015 at 08:52 AM 0
Share

Try Encoding.Unicode ins$$anonymous$$d of Encoding.UTF8

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Multiaki · Dec 10, 2015 at 05:23 PM

Here is the solution I found online. It worked for me. http://stackoverflow.com/questions/1615559/converting-unicode-strings-to-escaped-ascii-string

 static string DecodeEncodedNonAsciiCharacters( string value ) {
     return Regex.Replace(
         value,
         @"\\u(?<Value>[a-fA-F0-9]{4})",
         m => {
         return ((char) int.Parse( m.Groups["Value"].Value, NumberStyles.HexNumber )).ToString();
     } );
 }

Hope it helps!

Aki

Comment
Add comment · Show 2 · 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 Bunny83 · Dec 10, 2015 at 05:36 PM 1
Share

Uhm, that's the same link i posted in my answer...

Also make sure you read the comment below that answer on StackOverflow. The regular expression should be @"\\u(?<Value>[a-fA-F0-9]{4})" since only hex characters are allowed.

avatar image Multiaki Bunny83 · Dec 10, 2015 at 05:45 PM 0
Share

Thanks, Fixed

avatar image
0

Answer by Bunny83 · Dec 06, 2015 at 12:41 PM

You actually shouldn't do anything with encoding since the encoding classes are only responsible for character to byte and byte to character conversion. What you have in your string is just an "escaped" string.

You have to unescape it manually, that's all. Uri.UnescapeDataString is said to work as well.

Comment
Add comment · Show 2 · 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 Bunny83 · Dec 10, 2015 at 05:02 AM 0
Share

@tanuj0092:
Uhm, why did you downvote my answer? Any reason? If your string literally contains such escaped sequences you need to unescape them to get unicode characters. If your actual string contains unicode you don't have to do anything since C# supports unicode characters. As long as you use a font that supports your characters everything should be fine.

By downvoting without a comment / reason you won't get friends here... I did not downvote your question, you can check my activity log.

avatar image tanuj0092 · Dec 10, 2015 at 05:41 PM 0
Share

@Bunny83: Hey man! I didn't purposefully. I realized it late when nothing can be undone! I do know you didn't down vote this question.

Regarding the question, I was able to achieve it by simple stringify algorithm.

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

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

Related Questions

Scandinavian letters 'Æ', 'Ø' and 'Å' 2 Answers

Unity networking tutorial? 6 Answers

Split a string every 'n' characters? 5 Answers

Cyrillic characters displays as question marks. 0 Answers

Disabling google analytics 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