[Solved] Make UTF-8 the default in "Advanced save options..."

The Welkin Suite Forum

[Solved] Make UTF-8 the default in "Advanced save options..."



Make UTF-8 the default in "Advanced save options..."

  • Please log in to reply

#1
windows version welkinsuite

joachim.roesecke

    Posted 30 Nov 2017 and edited 18 Jan 2018

    Hi

    When I do the following, I am always stuck with a version of an apex class I cannot build:

    1. Create a class in Salesforce.
    2. Pull the class to TWS.
    3. Make a change and include a non-ASCII-character in the code.
    4. Build.
    5. Change to UTF-8 in "Advanced save options...".
    6. Build again.

    I am always getting some error related to the file not being in UTF-8 or an error trying to convert the file. UTF-8 is the standard in Salesforce and there should never be a case where a file has to be in a different format.

    Maybe I am missing something here, but this is really annoying.

    Yes, I can create a class also directly in TWS but can you tell me how I can set the API version for the new class in TWS? I cannot find it.

    Thanks & Regards,

    Joachim



    9 replies to this topic

    #2

    vlgubanovich

      Posted 30 Nov 2017

      Hi Joachim,


      Thank you for getting to us with this question.

      You can setup the 'Save documents as Unicode when data cannot be saved in codepage' option in the Tools -> Options -> Environment -> Documents. Please let me know if setting this option resolves your issue or if we'd need to look for some other ways of resolving it.


      Regarding your question about setting the API version for the new class - there is no such option during the class creation, however afterwards you are always able to modify "-meta.xml" files for your classes to change the API version. I'll also add to our backlog request for the option to select the API version while creating a class, however I can't for now predict the timeline for this ticket to be released.


      Hope this helps.


      Thank you,

      Vladimir


      Vladimir Gubanovich
      Head of Product
       
      The Welkin Suite
      skype id: vladimir.gubanovich
      e-mail: vladimir.gubanovich@welkinsuite.com


      #3

      joachim.roesecke

        Posted 01 Dec 2017

        Hi Vladimir

        Here is what happens when I create a class in TWS and change the API version afterwards ("Save documents as Unicode when data cannot be saved in codepage" is selected):

        1. Add --> Item --> Class (name "TestClass.cls")
        2. Class is created in SFDC in API version 39. Under "Advanced Save Options" I can see that the codepage is "Western European (Windows) - Codepage 1252".
        3. Change API version in "TestClass-meta.xml" to 41 and build.
        4. Class is now in API version 41.
        5. Add a non-ASCII-character to the class (e.g. "public String foo = 'barü';") and build.
        6. The class is saved to SFDC, TWS asks me if I want to refresh the class and the property looks like this: "public String foo = 'bar�';").
        7. Change the codepage to UTF-8 and the characters back to the original string again and build.
        8. The following error appears: "Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'."

        This is pretty annoying. Where can I set the default codepage? Is it taken from my system?

        Right now, the only way for me is to create new classes in Salesforce and include a non-ASCII-character before saving it. Only then I am able to work with the class in TWS.

        Thanks & Regards, Joachim



        #4

        vlgubanovich

          Posted 01 Dec 2017

          Hi Joachim,


          Thank you for the additional details provided.

          Can you please confirm that you've tried setting the 'Save documents as Unicode when data cannot be saved in codepage' option in the Tools -> Options -> Environment -> Documents? See the attached screenshot.


          If this option won't help you we'll look for another solution or at least a workaround for you as soon as possible.


          Thank you,

          Vladimir


          Attached Files

          Vladimir Gubanovich
          Head of Product
           
          The Welkin Suite
          skype id: vladimir.gubanovich
          e-mail: vladimir.gubanovich@welkinsuite.com


          #5

          joachim.roesecke

            Posted 04 Dec 2017

            Hi Vladimir

            As I stated in the first sentence above, the option "Save documents as Unicode when data cannot be saved in codepage" is selected.

            Thanks & Regards, Joachim



            #6

            joachim.roesecke

              Posted 04 Dec 2017

              Hi Vladimir

              This is getting ridiculous now. This behaviour even occurs if I introduce a non-ASCII character into a class which already exists for a long time and did not contain such characters before. The only workaround I can think of at the moment is to copy the contents of the class into an external text editor, delete the class and recreate it directly in Salesforce with the previously copied code. As you may imagine, the deletion may prove difficult if other classes already refer to the class in their code. This must be set up in a way that only Unicode is allowed for all files. Apparently, there is some auto-detection taking place in TWS (or in VS Isolated Shell) which saves files in the codepage of the system first (if there are only ASCII characters in it) and only saves it in Unicode once there is a non-ASCII character present. I cannot believe that I am the first person to encounter this.

              Thanks & Regards, Joachim



              #7

              vlgubanovich

                Posted 11 Dec 2017

                Hi Joachim,


                Thank you for more details.

                I've missed that sentence in your reply, so please sorry.

                You're right - it's a strange behavior of the Visual Studio shell to save in such a way. I've tried a couple existing VS extensions fighting with that issue, so you can use them as a workaround while we'll do this on our side, however they're tied up with regular types of files from the VS itself, so they won't work for TWS.

                I'll do my best to squeeze this change into the next release that'll take place somewhere next week.


                Thank you for your patience.


                Best regards,

                Vladimir


                Vladimir Gubanovich
                Head of Product
                 
                The Welkin Suite
                skype id: vladimir.gubanovich
                e-mail: vladimir.gubanovich@welkinsuite.com


                #8

                joachim.roesecke

                  Posted 12 Dec 2017

                  Hi Vladimir

                  Thanks for that. For anyone encountering this: the only workaround right now is to create all classes directly in Salesforce, include a non-ASCII character e.g. in a comment, save the class and pull it into TWS. After that, "Advanced Save Options..." always shows "Unicode" by default. It is however not possible to pull existing classes with no non-ASCII characters into TWS, add a non-ASCII character and expect the class to be saved to Salesforce.

                  Cheers, Joachim



                  #9

                  joachim.roesecke

                    Posted 16 Jan 2018

                    Hi 

                    With version 1.15.8.4 this problem seems to be resolved. I can now create classes in TWS with or without non-ASCII characters and even add such characters after the creation. It appears to me that with old projects still having non-UFT-8 files in it, I have to "Pull from Salesforce" a lot but I think that is how it is.

                    Cheers, Joachim



                    #10

                    kate.dulko

                      Posted 18 Jan 2018

                      Hi Joachim,


                      Thank you for your update.

                      We are happy that now you can create files and edit them using all the necessary characters.


                      I'll close the current topic as solved.


                      Best regards,

                      Kate


                      Kate Dulko
                      Customer Relations

                      The Welkin Suite

                      twitter: @KateDulko
                      skype id: d_katerina
                      e-mail: kate.dulko@welkinsuite.com

                       

                        


                      Boost Your Productivity. Get Started Today

                      Try Free Trial