Here is a problem that has been bothering me a lot about Python, I could really use some help on this:
I’m trying to read some string from a file. The files are .rc suffix where one kind of localized strings are inside for each file. Based on different languages, I used different codepage to decode. Here I only take French file as an example and its code page is 1252. Sadly, every time if there is a double quotes, when I print the string in Python shell, there will be two double quotes unexpectedly.
The line in .rc source file:
La fonction “Test de télécopie” vérifie.
The output string in Python shell:
La fonction “”Test de télécopie”” vérifie.
Some activities I did:
f = open(filename,"r") #Used to open .rc source file
for strline in f.readlines(): #Used to read file line by line
print strline #Used to print in Python shell
Additional Info:
a. The double quotes Hex code in .rc source string is: 
b. If I open the .rc source file with web browser, it also displays two double quotes unexpectedly.
c. The .rc source file is confidential, so I didn’t attach here.
d. OS: Enu Win7 x64\Python: v2.7
I’m a newbie for Python. Any ideas will be really really appreciated.
Best Regards,
😉
All the misunderstanding comes from that I’m not familiar with .rc files (I never used C++ before) and how does the developer handle the strings. Don’t punch me if my answer looks so untutored. 🙂
After talking with the relevant developers, it’s confirmed to be a mechanism added by the .rc file creators which is used to handle the double quotes in strings.
Like a string below:
GUI expects-How are you, “Mark”?
In .rc(or web browser)-“How are you, “”Mark”””?
The .rc file creators add this mechanism of adding one more double quotes to surround the original ones in strings, to ensure once the string is called to display in GUI, it will not be recognized as:
-“How are you,”Mark”?” ==>”How are you,” Mark “?”==>This would be a messy double quotes match which the GUI can not display correctly.
So I added a filter to remove this additional double quotes in order to get what I want. And I believe it’s easy for the Python users.
It’s not a professional answer, but I just hope to let the people who encountered same problem think from a different way.
I really appreciate to everybody that helped me identify the problem above before.