Dress codes abroad operate on two levels: the explicit rules and the unspoken expectations, and the second causes most newcomer confusion. Explicit rules are easy, cover shoulders and knees at certain religious sites, remove shoes indoors where required, follow the stated office policy. The unspoken layer is calibrated by observation: how formal is this office really, what do people wear to a dinner invitation, how does dress shift between the city center and conservative neighborhoods or rural areas.
Professionally, the safe strategy is to start one notch more formal than you think necessary and adjust down after watching colleagues for a week or two. Overdressing early is read as respect; underdressing is read as not taking things seriously. Industries differ wildly, of course, so let your actual workplace, not the country stereotype, set your baseline.
Socially there is more flexibility, and personal or religious dress is respected in most places. The sensible compromise is context-awareness: keep your identity, but adapt at religious sites, formal events, and conservative regions.