Use traits_type::to_int_type instead of casting to unsigned char