The degree character in Igor 7

Hi everyone!

While replacing one of our computer systems I just switched from Igor 6 to Igor 7. To my very surprise the previous code was not able to run any longer. One of the problems seems to be the degree character °. It appears, that inside the string it is more than one character long. I found a note that links this problem to UTF-8. I give a code example below.

Since we have a lot of Igor code and in the current project no time and mony to adapt it, I am now looking for any sort of pragma or switch we can use to maintain compatibility in a simple way. Is there e.g. anything I can use to switch off UTF-8 string coding?

Another problem seem to be image file formats like BMPf, which are not supported any longer. Also for this problem I am looking for a general pragma or switch that prevents me from reworking the code.

Best regards,
Joerg.


function Latt2Deg(Lattitude)
    string Lattitude
   
    variable pos
    string str
   
    variable d,m,s,sgn
   
    pos = strsearch(Lattitude,"°",0)
    if (pos<0)
        return str2num(Lattitude)
    endif
    str = Lattitude[0,pos-1]
    d = str2num(str)
    str = Lattitude[pos+1,9999] // this does not work any longer in Igor 7
    Lattitude = str
   
    pos = strsearch(Lattitude,"'",0)
    str = Lattitude[0,pos-1]
    m = str2num(str)
    str = Lattitude[pos+1,9999]
    Lattitude = str
   
    pos = strsearch(Lattitude,"\"",0)
    str = Lattitude[0,pos-1]
    s = str2num(str)
    str = Lattitude[pos+1,9999]
    Lattitude = str
   
    if (cmpstr(Lattitude[0], "N")==0)
        sgn = 1
    else
        sgn = -1
    endif
       
    return sgn * ( d + m/60 + s/3600)
end

It seems, that a degree character, which is read from an Excel file is well recognized, while a degree character, which is read from an ASCII file is no longer recognized as "°".


In Igor7, this:

pos = strsearch(Lattitude,"°",0)

searches for a Unicode degree sign (code U+00B0).

I don't know where string Lattitude came from. If you read it from a file using FReadLine, then you would need to convert it to Unicode using the ConvertTextEncoding function.
BMP bitmap files can still be read on Windows. Tell me more about your problem- are you reading a .BMP file, or trying to export graphics? Any format that depended on QuickTime is no longer supported.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Hi Howard,

thanks for your response. I fould the ConvertFileFormat operation and I spent half of the night fixing our program codes. In many caes, it worked. Wavemetrics provides indeed a nice documentation for this issue. Thanks! Nevertheless it took me hours to dig myself through this problem.

There are still some problematic projects. One example is a project where we use Igor to prototype image compression algorithms. There we do a lot of bit operations. We put 8-bit binary information into strings in order to look for patterns. Finding binary substrings is faster and far easier in strings than in waves. The entire code only works if strings can handle 8-bit chars. I cannot disclose the original code, but I give a short test example. It should produce a numerical wave b with a length of 256 counting from 0 to 255.

I tried to use  #pragma TextEncoding = "Binary" . That would indeed be very helpful. But it leaves a message There is a conflict between the file's text encoding and the TextEncoding pragma. How can I resolve this? On the procedure window bottom I can choose the procedure file encoding. But there is no choice for Binary.

Is there any way, I can get Igor back to process 8-bit strings (regardless of internal coding)?

Or is the only solution to go back to Igor 6 forever?

Best regards,
Jörg.


#pragma TextEncoding = "Binary"
#pragma rtGlobals=3     // Use modern global access method and strict wave access.

macro TestCoding()
    string/G a = ""
   
    variable i = 0
    do
        a += num2char(i)
        i +=1
    while (i<256)
   
    Make/O/N=(strlen(a)) b = char2num(a[x])
end



Check out the help for num2char, especially this:
Quote:
If you want a string containing a single byte, even though it may not be a valid UTF-8 string, pass 1 for options and num2char will return a string containing the single byte whose value is num , provided that num is between 0 and 255.