How to pass strings to scripts as parameters?

I want to call a script and pass a string argument.
When I try either a literal or a sensor state it does not transfer as I would expect.

text_sensor:
  - platform: version
    name: "Software Version"
    id: sw_version

script:
  - id: send_data
    parameters:
      sensor_id: string
      sw_version: string
    then:
      - logger.log:
          format: 'sw ver %s, id %s'
          args:
            - sw_version
            - sensor_id

and call with

  - script.execute:
      id: send_data
      sensor_id: abcdef
      sw_version: !lambda return to_string(id(sw_version).state);

The arguments are not passed properly (looks like addresses?)
[17:31:18][D][main:683]: sw ver \xccT\xff?, id \x98\xfc\xff?

Is it something to do with char* to string conversion?
I’ve tried to_string to no avail
Thanks

Hi. Assuming this is in YAML, does this HA Docs page help?
" Scripts - Home Assistant "
Referring to the “Passing Variables to Scripts” section…

Thanks @IanBJ
This is for ESPHome (on an esp8266) not HA.
I think I’m following the documentation it’s just the string being “sent” to the script is not being “received” properly.
It looks like when it gets to the script it’s the address of the string not the string itself.

Solved - you need .c_str() on the strings to use them
[converts std:string to char* ?]

script:
  - id: send_data
    parameters:
      sensor_id: string
      sw_version: string
    then:
      - logger.log:
          format: 'sw ver %s, id %s'
          args:
            - sw_version.c_str()
            - sensor_id.c_str()