Syntax
text=hexstr2str([hs,len])
Input Parameter
hs : | | rows |
len : | | hex numbers per row ; default is 40 (80 chars) |
Output Parameter
text : | | String array with [... x len] chars |
Examples
hs=str2hexsstr('The quick brown fox jumps over the lazy dog')
str2codelines(hs)
char(hexstr2str(hs')) % make shure that hs is a row vector
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, hexstr2str
, is designed to convert a uint8 string into a hex string array. It is particularly useful for integrating default content for special format files, such as DXF, into an m-function. The function is part of the SolidGeometry library and was introduced in version 5.0.
Input Parameters
- hs: This parameter represents the rows of the input data.
- len: This parameter specifies the number of hex numbers per row. The default value is 40, which corresponds to 80 characters.
Output Results
- text: The output is a string array with a length of [... x len] characters.
Algorithm Steps
- The function begins by defining a test string, which is a series of hex values representing the phrase "Dies ist ein Test".
- The function retrieves the input parameter
hs
using getfuncparams
, with the test string as a default value.
- The input
hs
is transposed to ensure it is a row vector.
- An empty uint8 array,
text
, is initialized to store the converted characters.
- A loop iterates over the
hs
array in steps of two characters (since each hex value is two characters long).
- For each pair of characters, the function checks if they are not spaces (' ').
- If the characters are not spaces, they are converted from hex to decimal using
hex2dec
and stored in the text
array.
- The loop continues until all characters in
hs
are processed.
- The function returns the
text
array, which contains the converted string.
Example Usage
The function can be used in combination with str2hexsstr
and str2codelines
to convert a string into a hex string and then back into a character array:
hs = str2hexsstr('The quick brown fox jumps over the lazy dog');
str2codelines(hs);
char(hexstr2str(hs'));
Algorithm explaination created using ChatGPT on 2025-08-19 07:26. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21