Updated fromChar to detect invalid characters