OK. The code motion is fine. However the UTF conversion is wrong. It mostly works for ASCII / English, but fails for more complicated things. libefivar has the right routines, and it would be good to find a way for libstand to share that with libefivar and use the libstand routines. That can be done in a followup commit though.

I'm quite sure it can be, but I would leave it as is for now, as the main purpose for this change is to move the code from efi/loader/main.c. Also there are some additional changes related to variables, so we have to return to this code anyhow, and then it is better time to review the logic here.