public static String fixIDN ( String addr ) { int pos = addr . indexOf ( ' ' ) ; if ( pos > 0 && pos < addr . length ( ) - 1 ) { String domain = addr . substring ( pos + 1 ) ; if ( ! StringUtil . isAscii ( domain ) ) { domain = IDN . toASCII ( domain ) ; return addr . substring ( 0 , pos ) + "@" + domain ; } } return addr ; }
converts IDN to ASCII if needed