Using UTF-8 in Memory Reading/ Apps (c#) menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    luciferc's Avatar Contributor
    Reputation
    90
    Join Date
    Jul 2008
    Posts
    373
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using UTF-8 in Memory Reading/ Apps (c#)

    So i am trying to get to read UTF-8 Characters etc. from Wow for diffrent lang Packs.

    And from websites as well.

    So far i have

    Code:
    UTF8Encoding utf8 = new UTF8Encoding();
    
    Byte[] byteArray = utf8.GetBytes(web.DownloadString("http://ru.wowhead.com/");
    string rusdata = utf8.GetString(byteArray); //Convert to String again
    
    "<title>Wowhead: **ŸÑ€**¸**º******»Ñ‹ **œÑƒ**»**³****Ñ€**° **±**µ**· ч**°Ñ‚**° **² **œÑƒ**»**³****Ñ€**µ.</title>" 
    
    This is what it returns from the title
    
    bunch of Mojibake
    -Any help appreciated.

    Using UTF-8 in Memory Reading/ Apps (c#)
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to do this;

    Code:
    byte[] responseBuffer = Encoding.ASCII.GetBytes(web.DownloadString("http://ru.wowhead.com/"));
    string rusData = Encoding.UTF8.GetString(responseBuffer);
    web.DownloadString returns it as ASCII. So you need to break it down to bytes via the ASCII encoding, and return it to a string via the UTF8 encoder.

    Edit: I must be really tired... anyway... the PROPER way to do this is as follows;

    Code:
    byte[] responseBuffer = web.DownloadData("http://ru.wowhead.com/");
    string rusData = Encoding.UTF8.GetString(responseBuffer);
    This avoids any byte shifting due to the encoding. (Downloading raw byte data never does any encoding conversions, so you don't lose anything.)
    Last edited by Apoc; 05-06-2009 at 07:39 PM.

  3. #3
    bouh2's Avatar Active Member
    Reputation
    28
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That my function :

    Code:
            private string Encode(string s)
            {
                byte[] l = Encoding.Default.GetBytes(s);
                return Encoding.UTF8.GetString(l);
    
            }
    Example :

    Code:
            public virtual string ObjectName
            {
                get { return Encode(WowReader.ReadASCIIString(WowReader.ReadUInt(WowReader.ReadUInt(BaseAddress + 0x1F4) + 0x078), 1024)); }
            }
    (Yeah it's the same code xD)

  4. #4
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by bouh2 View Post
    That my function :

    Code:
            private string Encode(string s)
            {
                byte[] l = Encoding.Default.GetBytes(s);
                return Encoding.UTF8.GetString(l);
    
            }
    Example :

    Code:
            public virtual string ObjectName
            {
                get { return Encode(WowReader.ReadASCIIString(WowReader.ReadUInt(WowReader.ReadUInt(BaseAddress + 0x1F4) + 0x078), 1024)); }
            }
    (Yeah it's the same code xD)
    Mmmm... you actually have that reversed.

    WoW uses UTF-8 encoding internally. Most (actually, I think all) Windows machines use ASCII as the default encoding. ASCII doesn't have the 'funky characters' that WoW uses for certain names in CN/RU/KR/etc. Always read your strings in as UTF-8, then convert them to ASCII if you need to. (Though, you're best off just leaving it as UTF-

  5. #5
    bouh2's Avatar Active Member
    Reputation
    28
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did not understand everything but I need this function because when I search a unit name with accents (ex : Le déchireur) I read "Le d@/chireur" with ASCII encode (or others chars)

  6. #6
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by bouh2 View Post
    I did not understand everything but I need this function because when I search a unit name with accents (ex : Le déchireur) I read "Le d@/chireur" with ASCII encode (or others chars)
    Which proves what I just said. WoW uses UTF-8 encoding. You should be reading strings in as UTF-8, not as ASCII. Using BlackMagic, it will do the encoding for you, so you get the exact string as it's represented in WoW.

  7. #7
    bouh2's Avatar Active Member
    Reputation
    28
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I did understand, Thank's for you ^^

  8. #8
    guizmows's Avatar Banned
    Reputation
    57
    Join Date
    Feb 2008
    Posts
    414
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx it help me too.

  9. #9
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Erm..

    Copy+Pasta from my Lib; This would return a utf-8/unicode string.

    Code:
                public string ReadUnicode(Process Proc, int Address) //>> Returns a Unicode string <<
                {
                    try
                    {
                        ReadProcessMemory(Proc.Handle, Address, bytes, bytes.Length, 0);
                        return UnicodeDecoder(bytes);
                    }
                    catch { return null; }
                }
    
                string UnicodeDecoder(byte[] bytes) //>> The function that returns a string from bytes in a Unicode format <<
                {
                    UnicodeEncoding unicode = new UnicodeEncoding();
                    string _s = unicode.GetString(bytes, 0, bytes.Length);
                    if (_s.IndexOf("\0") != -1)
                        _s = _s.Remove(_s.IndexOf("\0"), _s.Length - _s.IndexOf("\0")); //>> Remove any of our invalid positions <<
                    return _s;
                }


  10. #10
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by suicidity View Post
    Erm..

    Copy+Pasta from my Lib; This would return a utf-8/unicode string.

    Code:
                public string ReadUnicode(Process Proc, int Address) //>> Returns a Unicode string <<
                {
                    try
                    {
                        ReadProcessMemory(Proc.Handle, Address, bytes, bytes.Length, 0);
                        return UnicodeDecoder(bytes);
                    }
                    catch { return null; }
                }
    
                string UnicodeDecoder(byte[] bytes) //>> The function that returns a string from bytes in a Unicode format <<
                {
                    UnicodeEncoding unicode = new UnicodeEncoding();
                    string _s = unicode.GetString(bytes, 0, bytes.Length);
                    if (_s.IndexOf("\0") != -1)
                        _s = _s.Remove(_s.IndexOf("\0"), _s.Length - _s.IndexOf("\0")); //>> Remove any of our invalid positions <<
                    return _s;
                }

    My strings have embedded nulls. What now bitch! WHAT NOW!

  11. #11
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post

    My strings have embedded nulls. What now bitch! WHAT NOW!
    Nullable types a la C++!? kekeke

  12. #12
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Nesox View Post
    Nullable types a la C++!? kekeke
    No you nub, a string with embedded nulls (i.e. one that isn't null terminated but 'size' terminated).

  13. #13
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wasn't expecting that response.


  14. #14
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    No you nub, a string with embedded nulls (i.e. one that isn't null terminated but 'size' terminated).
    Ok

    using (var fillah = new Fillzor())
    {
    while(true){}
    }

  15. #15
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Nesox View Post
    Ok

    using (var fillah = new Fillzor())
    {
    while(true){}
    }

    Lolwtf.

    (filler)

Page 1 of 2 12 LastLast

Similar Threads

  1. [guide] how to create a wow bot using autoit (memory reading)
    By zamba1587 in forum WoW Memory Editing
    Replies: 17
    Last Post: 01-23-2017, 03:27 PM
  2. Memory reading using Delphi, advise please :-)
    By joostvanpoppel in forum WoW Memory Editing
    Replies: 1
    Last Post: 02-04-2012, 05:26 AM
  3. How do i know if a Bot is using memory reading / writing?
    By sturmtiger in forum WoW Bots Questions & Requests
    Replies: 1
    Last Post: 01-06-2011, 06:31 AM
  4. Target Postion Using Memory Reading
    By smallbadad in forum WoW Memory Editing
    Replies: 2
    Last Post: 03-08-2009, 03:08 PM
  5. [AutoIT3] WoW Cordinator (X,Y,MapID and rotation memory reading)
    By Vladinator in forum World of Warcraft Bots and Programs
    Replies: 22
    Last Post: 05-15-2007, 03:26 AM
All times are GMT -5. The time now is 11:21 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search