Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. UNICODE problem??

UNICODE problem??

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebugginghelpannouncement
15 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y york528

    I will check that Now I am not at my computer About TCHAR I use in a struct

    struct WORD_DATA
    {
    TCHAR word[10];
    unsigned int hashVal;
    unsigned int localAddr;
    };

    This struct is for READ & WRITE a UNICODE word file It saves the data about word so I can use them to segmentation So is that TCHAR using correct?? and what suggestion do you have forme in UNICODE programming? ;P

    E Offline
    E Offline
    Eytukan
    wrote on last edited by
    #6

    There's a nice article from Chris itself :Click[^]Search for "Reading and Writing ASCII text files" in the article. Your problem would be addressed. Also you may check this one:Clicky[^]

    He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

    Y 1 Reply Last reply
    0
    • E Eytukan

      There's a nice article from Chris itself :Click[^]Search for "Reading and Writing ASCII text files" in the article. Your problem would be addressed. Also you may check this one:Clicky[^]

      He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

      Y Offline
      Y Offline
      york528
      wrote on last edited by
      #7

      Release and Debug mode, I both defined _UNICODE, UNICODE I changed all TCHAR to wchar_t But the problem still exists :confused::confused::confused:

      E 1 Reply Last reply
      0
      • Y york528

        Release and Debug mode, I both defined _UNICODE, UNICODE I changed all TCHAR to wchar_t But the problem still exists :confused::confused::confused:

        E Offline
        E Offline
        Eytukan
        wrote on last edited by
        #8

        Are you using cout<< to display you string? Show me the link that creates the problem.

        He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

        Y 1 Reply Last reply
        0
        • E Eytukan

          Are you using cout<< to display you string? Show me the link that creates the problem.

          He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

          Y Offline
          Y Offline
          york528
          wrote on last edited by
          #9

          No I use cout to display a int value of the string The word lib save the string like this

          struct WORD_DATA
          {
          unsigned int hash;
          TCHAR word[10];
          unsigned int address;
          unsigned int localAddr;
          };

          I use fwrite to write a WORD_DATA and fread to read from the file First I segment string (such as "you") form source file and get the hash value of string then I go to hash table by index(unsiged int hash(such as 1020)) to find out if it in the table (if there is more than one word that having the same hash value I use wcscmp (wcscmp(WORD_DATA.word, "you")) to find the correct one) But Release mode it all failed (can't be found) and Debug it runs correctly At last if the word exists I push back the localAddr value to vector then display all the results But Release mode because all failed to find no results displayed :confused: X| If it still not clear I can post my program to you Thank you so much it's so kind of you

          E 1 Reply Last reply
          0
          • Y york528

            No I use cout to display a int value of the string The word lib save the string like this

            struct WORD_DATA
            {
            unsigned int hash;
            TCHAR word[10];
            unsigned int address;
            unsigned int localAddr;
            };

            I use fwrite to write a WORD_DATA and fread to read from the file First I segment string (such as "you") form source file and get the hash value of string then I go to hash table by index(unsiged int hash(such as 1020)) to find out if it in the table (if there is more than one word that having the same hash value I use wcscmp (wcscmp(WORD_DATA.word, "you")) to find the correct one) But Release mode it all failed (can't be found) and Debug it runs correctly At last if the word exists I push back the localAddr value to vector then display all the results But Release mode because all failed to find no results displayed :confused: X| If it still not clear I can post my program to you Thank you so much it's so kind of you

            E Offline
            E Offline
            Eytukan
            wrote on last edited by
            #10

            Tell me few things, 1. Are you writting the files in binary, or text mode? If text more, Are you able to read "see" the contents with your eyes? Are they written properly?

            york528 wrote:

            But Release mode it all failed (can't be found) and Debug it runs correctly

            2. Do you mean, the text file is written properly but it does not read the string properly? Also when you read the string "You" from the line, are you able to print the word on screen? 3. How do you construct the hash table? As and when you read the file you create the file? or it's loaded from somewhere? --*---* 4. I prefer using fstreams. Why do you use fwrite? any specific reason? 5. Send the solution to dejavunic@gmail.com 6. I'll fix it for you tomorrow. But I'm not sure if I'll be free. So keep trying. When I get time, I'll do it for you.

            He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

            Y 3 Replies Last reply
            0
            • E Eytukan

              Tell me few things, 1. Are you writting the files in binary, or text mode? If text more, Are you able to read "see" the contents with your eyes? Are they written properly?

              york528 wrote:

              But Release mode it all failed (can't be found) and Debug it runs correctly

              2. Do you mean, the text file is written properly but it does not read the string properly? Also when you read the string "You" from the line, are you able to print the word on screen? 3. How do you construct the hash table? As and when you read the file you create the file? or it's loaded from somewhere? --*---* 4. I prefer using fstreams. Why do you use fwrite? any specific reason? 5. Send the solution to dejavunic@gmail.com 6. I'll fix it for you tomorrow. But I'm not sure if I'll be free. So keep trying. When I get time, I'll do it for you.

              He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

              Y Offline
              Y Offline
              york528
              wrote on last edited by
              #11

              OK I'll send my code to you and give you a detailed description about my code I'll keep trying If I can't figure out this problem I won't sleep well :( And thank you sooooooo much

              1 Reply Last reply
              0
              • E Eytukan

                Tell me few things, 1. Are you writting the files in binary, or text mode? If text more, Are you able to read "see" the contents with your eyes? Are they written properly?

                york528 wrote:

                But Release mode it all failed (can't be found) and Debug it runs correctly

                2. Do you mean, the text file is written properly but it does not read the string properly? Also when you read the string "You" from the line, are you able to print the word on screen? 3. How do you construct the hash table? As and when you read the file you create the file? or it's loaded from somewhere? --*---* 4. I prefer using fstreams. Why do you use fwrite? any specific reason? 5. Send the solution to dejavunic@gmail.com 6. I'll fix it for you tomorrow. But I'm not sure if I'll be free. So keep trying. When I get time, I'll do it for you.

                He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

                Y Offline
                Y Offline
                york528
                wrote on last edited by
                #12

                Hi VuNic I found the mistake but I don't know why?? This is my hash function

                int Hash::HashValUnicode(const TCHAR* src, const int nArrayLen)
                {
                register unsigned int h;

                while (\*src)
                {
                	h = (h<<5) + h + \*src++;
                }
                
                return h % nArrayLen;
                

                }

                In Debug and Release Mode It gives diffirent hash values of the same UNICODE string Such as "you" Debug it give 123 but Release 542(Just a example) How dose it happened ??? Bad hash function???

                1 Reply Last reply
                0
                • E Eytukan

                  Tell me few things, 1. Are you writting the files in binary, or text mode? If text more, Are you able to read "see" the contents with your eyes? Are they written properly?

                  york528 wrote:

                  But Release mode it all failed (can't be found) and Debug it runs correctly

                  2. Do you mean, the text file is written properly but it does not read the string properly? Also when you read the string "You" from the line, are you able to print the word on screen? 3. How do you construct the hash table? As and when you read the file you create the file? or it's loaded from somewhere? --*---* 4. I prefer using fstreams. Why do you use fwrite? any specific reason? 5. Send the solution to dejavunic@gmail.com 6. I'll fix it for you tomorrow. But I'm not sure if I'll be free. So keep trying. When I get time, I'll do it for you.

                  He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

                  Y Offline
                  Y Offline
                  york528
                  wrote on last edited by
                  #13

                  OK It works Just because register unsigned int h; I should initail h;

                  register unsigned int h = 0;

                  like this both debug and release give the same hash value such a little thing drive me crazy now it's ok thank you so much and can we make a friend? Emails me your MSN ID OK? this email addr isn't my msn ID Mine is techieyork@hotmail.com

                  E 1 Reply Last reply
                  0
                  • Y york528

                    OK It works Just because register unsigned int h; I should initail h;

                    register unsigned int h = 0;

                    like this both debug and release give the same hash value such a little thing drive me crazy now it's ok thank you so much and can we make a friend? Emails me your MSN ID OK? this email addr isn't my msn ID Mine is techieyork@hotmail.com

                    E Offline
                    E Offline
                    Eytukan
                    wrote on last edited by
                    #14

                    There's a lot of difference between Release & Debug modes. In debug mode variable gets automatically initialized. So you will not get an undefined behavior. But it's not the case with Release. And there's a lot of other differences between them. If you go through the below article, you'll get an idea. Check This one[^]

                    He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

                    Y 1 Reply Last reply
                    0
                    • E Eytukan

                      There's a lot of difference between Release & Debug modes. In debug mode variable gets automatically initialized. So you will not get an undefined behavior. But it's not the case with Release. And there's a lot of other differences between them. If you go through the below article, you'll get an idea. Check This one[^]

                      He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

                      Y Offline
                      Y Offline
                      york528
                      wrote on last edited by
                      #15

                      Thank you :-O

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups