Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Null characters in txt file (ascii - utf?)

    Cinema 4D SDK
    c++ windows r20
    3
    8
    3.7k
    Loading More Posts
    • 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.
    • P
      pim
      last edited by r_gigante

      I have a command plugin that sends the console output to a txt file.
      However, there are - at the beginning of each line - strange (Null characters).

      For example (I use Notepad++ to look at the output text file):

      0_1538389006030_ascii-nul.JPG

      Filename fn = GeGetPluginPath() + "consolelog.txt";
      BaseFile *bf = BaseFile::Alloc();
      if (!bf->Open(fn, FILEOPEN::WRITE, FILEDIALOG::NONE))
      	return false;
      bf->WriteString("Start log regels."_s + "\n");
      ...
      bf->WriteString("Einde log regels."_s + "\n");
      bf->Close();
      BaseFile::Free(bf);
      

      I think it has something to do with ascii versus utf?

      What can I do to get rid of these non ascii characters and just have plain ascii characters in my text file?

      -Pim

      1 Reply Last reply Reply Quote 0
      • P
        pim
        last edited by

        Ok, what I detected is that WriteString() inserts characters before the string.
        If I use WriteChar(outString[i]), it is ok.

        The question remain, why does WriteString add characters?

        for (i = 0; i < outString.GetLength(); i++)
        {
        	fn->WriteChar(outString[i]);
        }
        
        1 Reply Last reply Reply Quote 0
        • M
          mp5gosu
          last edited by

          https://developers.maxon.net/docs/cpp/2023_2/page_manual_basefile.html#page_manual_basefile_byte_access

          1 Reply Last reply Reply Quote 2
          • a_blockA
            a_block
            last edited by

            Hi Pim,

            @mp5gosu already gave the link to the relevant manual in our docs.
            BaseFile and HyperFile classes store additional datatype information to a file. To avoid this you need to use the direct byte access, mp5gosu linked to.

            Bye,
            Andreas

            1 Reply Last reply Reply Quote 0
            • M
              mp5gosu
              last edited by

              By the way, I left the link uncommented intentionally, as all what is written there would have been a simple copy/paste. πŸ™‚

              1 Reply Last reply Reply Quote 0
              • a_blockA
                a_block
                last edited by

                @mp5gosu Sorry, I didn't want to lower the efficiency of this thread. We really appreciate your contributions. Just sometimes I feel the urge to add a few more words for future readers. It's not my intention to lower the value of your contribution (I also up-voted your post). I hope you don't mind.

                M 1 Reply Last reply Reply Quote 0
                • M
                  mp5gosu @a_block
                  last edited by

                  @a_block sure, will keep it in mind for future posts - you're absolutely right!

                  1 Reply Last reply Reply Quote 0
                  • P
                    pim
                    last edited by

                    Thanks very much.

                    (There is so much information to be read!).

                    -Pim

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post