Skip to content

snippets/python/string-manipulation/convert-string-to-ascii is non-representative of function #192

Closed
@MinerMinerMods

Description

@MinerMinerMods

What general issue would you like to create?

When testing convert-string-to-ascii.py code for errors, I ran this code:

string_to_ascii('�') # returns 1114111

The string uses the character "U+10FFFF" if this code was actually converting to ASCII it should have aborted this code as U+10FFFF is not in the ASCII set.

I was expecting the code to crash or throw however this never happened. The code instead returns 1114111 or 0x10FFFF in decimal. ASCII only includes the numbers 0 to 255(0xFF) as its addressable range. This could cause behavior and assumptions not accurate to reality.

Change suggestions:

  • Replace all references to ASCII with Unicode
  • Rename file to convert-string-to-unicode.py or another accurate name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions