Under what circumstances are non-ASCII Keycodes generated?

When testing the latest release of SDL (2.0.5) on my Windows machine (with French and Russian layouts), I find that non-ASCII Unicode characters are never generated for the keycode (the sym field of SDL_Keysym) of key down or key up events. What actually happens when a key corresponding to such a character is pressed is that the keycode is the same as the scancode. For example, when è is pressed in a French layout, the keycode and scancode are both the ASCII digit 7 (0x37). This behavior is also observed on some (I think most) Linux systems.

However, when I tried this experiment in an Ubuntu VM in VirtualBox, the keycodes were in fact equal to the Unicode characters generated by an unmodified press of the corresponding keys (except when I changed the layout while running the test program, which made them go out of sync…). So what factors determine which behavior SDL has? E.g. the Linux distro, the desktop environment, or the minor version of SDL. Does it matter that I’m using a VM?

Also, is it expected that SDL will move towards one or the other behavior consistently across platforms?