Is there a good way to check a string for the proper length when I convert it to an Bson objectID. The object ID length must be 24 characters, which works fine when using ASCII characters, but breaks if someone adds an accented letter (e.g. é), as this takes up two characters. I know that I can use regular expressions to halt the program if an accented letter (or nonASCII-style letter) is found, but is there a more proper way to do this?

When I do an ID search for BsonObjectID.fromString("55981e8fbea1ebc0dba665a8"), it works fine.
When I do an ID search that has an accented letter, 55981é8fbea1ebc0dba665a8, it breaks.