As a foreigner in, say, Germany or Zambia, I would respectfully stand in silence while the national hymn of said country was being played - but I would not place my hand over my heart or, e.g., bow or genuflect.
The Code apparently requires everyone (including foreigners) to place the hand over the heart - which I (as an American) would personally find distasteful.
Regards,
One’s personal distaste and The Code do not have to be in harmony with each other. Isn’t it great to be an American citizen?