Skip to content

Fix to handle newlines appropriately. #9

Description

@mcaidans

When sending SMS, newlines will be counted as 2 chars. Currently the code does not handle this (besides \r\n).
Find below my fix for this to rectify this issue.
main.py 18-21

NL_CHARS = {
        '\n': 10,
        '\r': 13
    }

main.py 76-88

nl_count = 0
for index, c in enumerate(textlist):
    if c == cls.NL_CHARS['\n']:
        if index >= 1 and textlist[index - 1] == cls.NL_CHARS['\r']:
                # If part of \r\n keep count same (remove 1 as chars counted as 2 in first place)
                nl_count -= 1
                continue

        nl_count += 1
    elif c == cls.NL_CHARS['\r']:
        nl_count += 1

length += nl_count

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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