Given a string, write a function to reverse it and handle edge cases such as special characters and whitespace.