MS Access VBA code editor character encoding and c

2019-05-10 15:01发布

问题:

What is the actual encoding used in Access' VBA editor? I have been searching for a concrete answer for quite a while but with no luck.

I thought it was UTF-8 but I'm not very certain.

My main issue is that when writing a query in VBA I sometimes need to test it in Access' query editor. When copy-pasting however, I lose my native characters (greek in my case) as they turn to gibberish.

I have tried pasting in a text editor and saving it as different encodings but I can never recover the original characters.

Thanks in advance.

Edit

Let me explain this a bit further:

As you can see I can write my greek characters in the VBA editor normally:

However, copying the first line in Access' query editor, I get the following:

Same goes for a simple text editor:

So I am inclined to think that the problem lies inside the clipboard, due to the encoding used for the greek characters. I guess they are not Unicode, as I indeed have to make the change in the System Locale for non-unicode characters. So how are these characters saved/copied? In what encoding?

Answer

Actually this problem was solved by switching the keyboard input language to greek (EL), when copying the actual test string.

I am still not sure however, as to why that happens. If anyone can provide some insight into this, I would love to hear it.

Thanks again

回答1:

The VBA editor does not support Unicode characters, either for input or display. Instead, it uses the older Windows technology called "code pages" to provide support for non-ASCII characters.

So, the character encoding in the VBA editor corresponds to the code page that is used by the Windows system locale as specified in the "Regional and Language Options" control panel. For example, with my system locale set to "Greek (Greece)"

I can enter Greek characters into my VBA code

However, if I switch my Windows system locale back to "English (United States)"

and re-open my VBA project, the Greek characters have changed to the corresponding characters in the new code page



回答2:

If "Control Panel" -> "Regional and Language Options" -> "System Locale" is set correctly but you still suffer from this problem some times then note that while you're copy-pasting your keyboard layout must be switched to the non-English language.

This is applicable to all non-unicode-aware applications not only VBA.

Credit goes to @parakmiakos



回答3:

details in this: http://www.pcreview.co.uk/forums/use-greek-characters-visual-basic-editor-t2097705.html

Looks like making sure your OS is set properly, and font choice inside the VBA editor.