Font message when opening file (fixed)

Font message when opening file (fixed)

7
NewbieNewbie
7

    Dec 20, 2011#1

    Hello.
    I hope someone can help.

    UE suddenly started showing a message when I open a specific file I have been working on without problems for weeks.
    The message is: "In order to view the document correctly, you may have to change your font and/or script settings in the Font Dialog."
    After closing the message, the file is there and can be edited, but all operations (even cursor movement) is considerably slower than in other files, even if they are opened simultaneously.

    The font is set to "Courier new, Regular, 8pts" and the script setting is "Western", as it has been for years.
    All other files open without message.

    If tried to copy the contents of the file, paste it into notepad, save it and open it in ultraedit.
    Doing this I noticed that the problem is really weird.
    When saving the file from notepad, I gave it a different name.
    This file opened in UE without a problem.
    So, believing I had solved the problem, I deleted the original file and renamed the notepad file.
    But when I opened that file, bingo, there's the message again.

    Playing around I noticed that whenever I change anything in the name the problem is gone.
    When I change the name back to it's original, there it is again.

    The name of the file that is causing the message is car$migratie.pcb.
    changing a single letter in either the extension or the basename makes the message disappear.
    Changing it back, well you get the point by now.
    Since changing the basename also makes the message go, it can (imho) not be caused by the extension (and thus the syntax highlighting file). I also come to this conclusion because all other files with the same extension have no problems at all.

    I was using UE 17.20 when the message first occurred. I tried if upgrading to the latest version 17.30.0.1012 would solve it, but no luck

    6,681583
    Grand MasterGrand Master
    6,681583

      Dec 20, 2011#2

      There are two possible reasons for this warning message.
      • At Advanced - Configuration - File Handling - Code Page Detection the setting Auto code page detection is enabled and UltraEdit thinks the opened file uses a code page different to system code page. This is most like not the case according to what you have written. See topic Message about change of font and/or script settings in font dialog for more information about this feature and code page usage and settings in general.
      • Second on opening the file with File Open the option Format was set to a code page different to system code page.
      I detected and also reported already to IDM some days ago that since UE v17.20 the Format option in File Open dialog is sometimes not correct initialized with system code page (1252 (ANSI - Latin I) in my case), but is preset with 10000 (MAC - Roman). Opening the file without correcting the code page results in display of this warning message and scrolling becomes very slow. The reason for the wrong initialization behavior of the Format option is probably a not initialized variable of File Open dialog.

      UltraEdit remembers in uedit32.ini files opened or edited with a code page different to system code page, so that on next opening (or reload) the file is edited again with this code page.

      You can either close the file and re-open it again using File - Open and select the first item in the Format list above 10000 (MAC - Roman) before pressing button Open, or you click with this file active on View - Set Code Page and select the code page equal the system code page.

      If you want to get rid off all remembered file names with code page number, close all instances of UltraEdit, open %APPDATA%\IDMComp\UltraEdit\uedit32.ini with Notepad (not with UE), search for [File Code Page], delete the entire group, save and close the file and Notepad. Unfortunately the Clear History button at Advanced - Configuration - Toolbars / Menus - Miscellaneous does not clear this list in comparison to all other lists which are removed from uedit32.ini when pressing this button. I reported this also long time ago to IDM. Update: Starting with UE v18.10 the entire section [File Code Page] is also removed when using the button and no file open or using the setting to clear all histories on exit.

      Please report this problem also to IDM by email. The more users report it the higher is the priority for fixing it.

      7
      NewbieNewbie
      7

        Dec 20, 2011#3

        Mofi, I love you ;-)

        You are 100% right.
        I cleared the [File code page] section and the problem is gone.
        Indeed, when I use 'file - Open' the dialog says 'Format: 10000 (MAC Roman)'.

        Now that I know this I will try to remember to either not use the open dialog, or to change the 'format'.
        At least now I know how to fix it if I screw it up again.

        I will report the bug to IDM by mail later today.

        Thanks,

        Erik

        9
        NewbieNewbie
        9

          Dec 20, 2011#4

          I reported this on 2011/12/13.

          Here is the reply:
          IDM wrote:Thank you for your message, and I apologize for the trouble with this. We recently had another user report this, and our developers have been notified of the issue. We will correct this in a future update, and we'll email you as soon as it's available.
          I started having this issue once I updated to build 1011 (and 1012) of 17.30.

          I did not have this issue when using 17.30.1005.

          6,681583
          Grand MasterGrand Master
          6,681583

            Dec 20, 2011#5

            This problem definitely exists since UE v17.20.0.1005 (first public UE v17.20), at least for Windows XP/2K. The File Open dialog for Windows 7 / Vista is a different one and therefore it could be that this issue does not exist on Windows 7 / Vista. But I could never reproduce the problem of wrongly initialized Format option immediately after seeing that a file was opened with wrong code page preset with UE v17.20. But after updating to UE v17.30.0.1011, I could find out when it happens (in build 1011 and 1012 only). I sent IDM an email with the steps to reproduce and IDM support could reproduce it. But with the same steps the problem is not reproducible with a previous version of UltraEdit. If you read below the steps to reproduce and take into account that the problem only occurs sometimes and not always, you get the idea why I think the problem is caused by a not initialized variable before usage because then current value on stack determines the value of the variable.

            Here is the email I sent to IDM to report this problem:

            I'm using currently UltraEdit v17.30.0.1011 on Windows XP SP3 x86 with Windows Classic theme. Today I found out when "Format" is not initialized correct in "File Open" dialog.

            The problem is that sometimes the second item "10000 (MAC - Roman)" is selected on opening the dialog instead of first item "1252 (ANSI - Latin I)" as it should be on my computer all the time.

            The steps to reproduce the problem:
            • Delete entire directory "%appdata%\IDMComp\UltraEdit" while no instance of UltraEdit is running.
            • Start UltraEdit which creates now all user configuration files completely new.
            • Press Ctrl+O to open the "File Open" dialog and you see the "Format" option is correct initialized with "1252 (ANSI - Latin I)" selected, see OpenFileFormat_PowerUser.png
            • Click on button "Cancel" to cancel opening a file.
            • Right click on any toolbar and select "Advanced" instead of "Power User".
            • Press Ctrl+O to open the "File Open" dialog again. What do you see now selected for "Format"? I see now "10000 (MAC - Roman)" selected, see OpenFileFormat_Advanced.png
            • Click on button "Cancel" to cancel opening a file.
            • Right click again on any toolbar and select again "Power User".
            • Press Ctrl+O and look, "1252 (ANSI - Latin I)" is selected.
            I analyzed that further and made the same steps with UE v17.10.0.1015, UE v17.20.0.1016 and also UE v17.30.0.1002. But with these versions of UltraEdit the problem could not be reproduced using above steps.

            Therefore I switched again to UE v17.30.0.1011 and I could again reproduce the problem with the steps above. Same problem exists with using my customized toolbar. Switching to toolbar Power User and code page is correct selected in "File Open" dialog. Switching back to my customized toolbar and "Format" is set to "10000 (MAC - Roman)".

            Okay, what is the difference between Power User and Advanced toolbars? None! Both contain the same toolbars and commands. But when you look on the screen shots you see that the toolbars are positioned different.

            After some further tests I could see that indeed the layout of the UltraEdit main window has an effect on which code page is selected in the "File Open" dialog by default after opening with build 1011.

            I'm writing also Windows applications in C++ and with this behavior it is quite clear for me what happens here. There is no code in the OnInitDialog routine for File Open dialog for Windows 2000 / XP which really selects list item 0 of the Format list or the variable used to
            set the selection is not initialized. In other words the call of FormatList->SetCurSel(0); is missing in source code or most likely FormatList->SetCurSel(nSelect); is present in code, but variable nSelect is not initialized and therefore the value of this variable depends on the bytes in stack.

            Please forward this issue to your developers. In UE 17.30.0.1011 the code page is really nearly always set wrong on initial File Open after startup of UltraEdit and it happened also several times that "File - Revert to Saved" resulted in reloading the file suddenly with code page 10000 although code page detection was not enabled and the file was a pure ASCII file (no characters greater 127 decimal).

            The problem for us - the users - is that wrong behavior caused by the usage of a not initialized variable (perhaps only in some cases) can't be really worked around. We have to wait for a future version were this issue is fixed in source code.

            Well, there are 2 workarounds.

            We can open files in UltraEdit with any other method then using File - Open because this problem exists only when using File Open dialog.

            Or we take care on what is selected for Format in File Open dialog before opening a file, and click inside the drop down list and press key UP ARROW to select the system code page when wrong code page is selected because of this bug.

            7
            NewbieNewbie
            7

              Dec 29, 2011#6

              Since I keep forgetting to not use the file-open dialog, I keep running into this problem.
              So, being an IT guy I decided to automate the solution.

              I made a visual basic script that removes (if present) the [File Code Page] section from file %APPDATA%\IDMComp\UltraEdit\UEdit32.INI.
              I thought I'd better share, so if you like to have this too, you can download it from http://www.evrocs.nl/download/ue/ResetUECodePage.zip.
              Before people start calling me names because they feel the script could be done better/faster/more robust/whatever: I am not a vb developer, so you're probably right, do it better and post the new and improved version.

              If you're uncomfortable with downloading from unknown sources (understandable), you can also just copy the code below and paste it in your favourite text editor ;-)
              After reviewing what it does you can save it as a *.vbs file, and you're a double-click away from salvation.

              Just to make sure I don't get sued:
              You can get the script (download or copy paste) for free, and you can do anything you want (within the boundaries of your local laws off course) with it.
              The script, however, is provided as is, and although tested, is not guaranteed to be bug free.
              It's your own responsibility to review the code. If you decide to trust the code and run the script, this decision is completely yours, as are all consequences.


              Ok now for the fun part
              Here it is:

              Code: Select all

              '--
              '-------------------------------------------------------------------------
              '--                                                                     --
              '--       _/_/_/_/              _/_/_/      _/_/      _/_/_/    _/_/_/  --
              '--      _/        _/      _/  _/    _/  _/    _/  _/        _/         --
              '--     _/_/_/    _/      _/  _/_/_/    _/    _/  _/          _/_/      --
              '--    _/          _/  _/    _/    _/  _/    _/  _/              _/     --
              '--   _/_/_/_/      _/      _/    _/    _/_/      _/_/_/  _/_/_/        --
              '--                                                                     --
              '-------------------------------------------------------------------------
              '--
              '********************************************************************************
              '* Name        : RestUECodePage.vbs
              '* Funktie     : Script searches for the [File Code Page] section in file
              '*               %APPDATA%\IDMComp\UltraEdit\UEdit32.INI
              '*               If the section is found, it is removed.
              '*               
              '* Author      : Erik van Roon
              '* Dependencies
              '* ----------------
              '* - None
              '* -------------------------------------------------------------------------------
              '* Changes:
              '* Version  When        Who  What
              '* -------  ----------  ---  ---------------------------------------------------
              '* 1.0      29-12-2011  ERO  Initial version
              '*********************************************************************************
              
              option explicit
              
              Const cnForReading = 1
              Const cnForWriting = 2
              Const cnCodePageSection = "[File Code Page]"
              Const cnSectionNameStart = "["
              Const cnSectionNameEnd = "]"
              
              Dim Fso
              Dim File
              Dim FileLine
              Dim FileContentsNew
              Dim CompareMode
              Dim CodePageSectionFound
              Dim NextSectionFound
              Dim filename
              Dim ScriptName
              
              ScriptName = Wscript.ScriptName
              filename = getfilename
              
              CompareMode = vbTextCompare
              
              Set Fso  = CreateObject("Scripting.FileSystemObject")
              
              'Open file for reading
              If Not Fso.FileExists(filename) Then
                ReportError "Unable to find file: " & vbCrLf & vbCrLf & filename
              End If
              Set File = Fso.OpenTextFile(FileName, cnForReading)
              
              'Change contents
              CodePageSectionFound = False
              NextSectionFound = False
              Do Until File.AtEndOfStream
                FileLine = File.ReadLine
                
                CodePageSectionFound = CodePageSectionFound _
                                       Or Trim(FileLine) = cnCodePageSection
                NextSectionFound = NextSectionFound _
                                   Or (CodePageSectionFound _
                                       And Trim(FileLine) <> cnCodePageSection _
                                       And Left(Trim(FileLine),1) = cnSectionNameStart _
                                       And Right(Trim(FileLine),1) = cnSectionNameEnd _
                                      )
              
                'Only include current line in new file version if before or after cnCodePageSection
                If Not CodePageSectionFound _
                Or NextSectionFound _
                Then
                  FileContentsNew = FileContentsNew & FileLine & vbCrLf
                End If
              Loop
              File.Close
              
              'Open file for writing, write new contents and close the file
              If Not CodePageSectionFound Then
                ShowMessage "No changes needed for file " & vbCrLf & vbCrLf & filename
              Else
                If Not Fso.FileExists(filename) Then
                  ReportError "Unable to find file: " & vbCrLf & vbCrLf & filename
                End If
                Set File = Fso.OpenTextFile(FileName, cnForWriting)
                File.WriteLine FileContentsNew
                File.Close
                
                ShowMessage "Section 'File Code Page' removed from file" & vbCrLf & vbCrLf & FileName
              End If
              
              '==============================================================================
              'Return name of file that needs to be changed
              '==============================================================================
              Function GetFileName
                Const cnUEDir = "IDMComp\UltraEdit\"
                Const cnUEFile = "UEdit32.INI"
                
                Dim AppData
                Dim Shell
              
                Set Shell = CreateObject( "WScript.Shell" )
                AppData = Shell.ExpandEnvironmentStrings( "%APPDATA%" )
                If Right(AppData,1) <> "\" Then
                  AppData = AppData & "\"
                End If
                
                GetFileName = AppData & cnUEDir & cnUEFile
              End Function 'GetFileName
              
              '==============================================================================
              'Report error and quit
              '==============================================================================
              Sub ReportError (Message)
                MsgBox Message, VBOKOnly, ScriptName & " Script Error"
                WScript.quit
              End Sub 'ReportError
              
              '==============================================================================
              'Show message
              '==============================================================================
              Sub ShowMessage (Message)
                MsgBox Message, VBOKOnly, ScriptName
                WScript.quit
              End Sub 'ReportError

              9
              NewbieNewbie
              9

                Feb 21, 2012#7

                I received a hotfix for 17.30 to test.

                I have been using it for a few days and it does solve the issue.

                My guess is this will be pushed out soon for everyone.

                6,681583
                Grand MasterGrand Master
                6,681583

                  Feb 25, 2012#8

                  This bug was fixed with UE v17.30.0.1016 and UES v11.20.0.1010. Please update your UE v17.30.0.xxxx respectively UES v11.20.0.xxxxx.