Hi Guys,
Is it possible to split strings by its byte value?
The problem is to split a string by its byte value and store the data into respective columns in data table.
Hi @Chendoran_M
Can you be more specific on what is needed . Will substring and combination of indexOf not sufficient for you to achieve this?
cheers
String value= “21日本語能力ABC 203403” → “21” “日本語能力” “20” “34” “03”
After splitting the string the data must be stored in a data table;
column-1 column-2 column-3 column-4 column-5
“21” “日本語能力” “20” “34” “03”
*Here each Japanese characters are 2 bytes and English characters are 1 byte.
Hi @Chendoran_M
Use Substring as below …change the values accordingly to get other numbers as well
I saw a space after the Chinese word so got the index of that space and subtracted with 3 because there are 3 characters before the Chinese string . SO to get length I used it that way
cheers
Hi,
Where does ABC goes? Do you need to split as 2bytes 10bytrs, 2bytes,2bytes,2butes?
Regards,
ABC goes along with Japanese character. 2bytes,14bytes,2bytes,2bytes,2bytes.
Hi,
Hope the following sample helps you.
arrBytes = System.Text.Encoding.GetEncoding("shift_jis").GetBytes(yourString)
s = System.Text.Encoding.GetEncoding("shift_jis").GetString((arrBytes.Take(currentItem).ToArray))
Sample20221206-1a.zip (3.0 KB)
Regards,
The data is in Excel and I have used “Read Range Workbook” activity and stored the data in a variable to read the data and using “For Each Row in Data Table” to loop the split activity as per your solution. But I’ve got the below as my output!
Hi,
Can you share your input and expected output?
Regards,
shiftData.xlsx (10.0 KB)
Hi,
Can you try this?
Main.zip (2.6 KB)
However it doesn’t seem very good logic to split by byte value.
Regards,
FYI, it might be better to use regex as the following
m = System.Text.RegularExpressions.Regex.Match(CurrentRow(0).ToString,"(\d{2})(\D+)(\d{2})(\d{2})(\d{2})?(\d{,2})?")
Sequence.zip (2.1 KB)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.