Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] support special char1/2 in MetaString Encoding #1983

Closed
chaokunyang opened this issue Dec 16, 2024 · 3 comments · Fixed by #1987
Closed

[Python] support special char1/2 in MetaString Encoding #1983

chaokunyang opened this issue Dec 16, 2024 · 3 comments · Fixed by #1987
Assignees
Labels
enhancement New feature or request python

Comments

@chaokunyang
Copy link
Collaborator

chaokunyang commented Dec 16, 2024

Feature Request

In java MetaStringEncoder, we can pass special char1/2 likenew MetaStringEncoder('$', '_'), then the encoding and decoding will encode such chars specially:

  private int charToValueLowerUpperDigitSpecial(char c) {
    if (c >= 'a' && c <= 'z') {
      return c - 'a';
    } else if (c >= 'A' && c <= 'Z') {
      return 26 + (c - 'A');
    } else if (c >= '0' && c <= '9') {
      return 52 + (c - '0');
    } else if (c == specialChar1) {
      return 62;
    } else if (c == specialChar2) {
      return 63;
    } else {
      throw new IllegalArgumentException(
          "Unsupported character for LOWER_UPPER_DIGIT_SPECIAL encoding: " + c);
    }
  }

Currently those chars are hard coded in python:

        elif bits_per_char == 6:
            if "a" <= c <= "z":
                return ord(c) - ord("a")
            elif "A" <= c <= "Z":
                return 26 + (ord(c) - ord("A"))
            elif "0" <= c <= "9":
                return 52 + (ord(c) - ord("0"))
            elif c == ".":
                return 62
            elif c == "_":
                return 63
            else:
                raise ValueError(
                    f"Unsupported character for LOWER_UPPER_DIGIT_SPECIAL encoding: {c}"
                )

We should support pass those chars in python

Is your feature request related to a problem? Please describe

No response

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

@chaokunyang
Copy link
Collaborator Author

cc @pandalee99

@pandalee99 pandalee99 self-assigned this Dec 16, 2024
@pandalee99 pandalee99 added enhancement New feature or request python labels Dec 16, 2024
@pandalee99
Copy link
Contributor

sure,pretty good.

@pandalee99
Copy link
Contributor

I estimate that this demand will be completed between the 21st and 22nd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants