Skip to content

Add ord and chr functions #1558

@simplepad

Description

@simplepad

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Use Cases

My particular use case is checking bit flags in a string of raw bytes. When #1386 lands, it will add the required comparison functions, but I also need a way to convert a raw byte (a string) into an integer.

Attempted Solutions

No response

Proposal

Add two functions:

  1. ord(value: string, [position: integer]) - gives integer representation of the first character in a string (optionally the character at a certain position), this is a workaround for VRL not having a character type.
  2. chr(value: integer) - converts an integer into a character, the inverse of ord()

These functions should probably be added to the "Convert functions" section.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featureA value-adding code addition that introduce new functionality.vrl: stdlibChanges to the standard library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions