[Gambas-user] How to manage filenames whit invalid characters in gambas.

Jussi Lahtinen jussi.lahtinen at gmail.com
Thu Feb 16 18:13:51 CET 2023


"or" should be "use"...


Jussi

On Thu, Feb 16, 2023 at 7:10 PM Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:

> You need to use string class to iterate unicode strings.
> IE instead of Chr() or String.Code().
>
>
> Jussi
>
> On Thu, Feb 16, 2023 at 10:32 AM Martin <mbelmonte at belmotek.net> wrote:
>
>> El 15/2/23 a las 23:37, Bruce Steers escribió:
>> > They need fixing. By you. First.
>>
>> ok, so far I have solved it like this:
>>
>> Static Public Function Flat3(s As String) As String
>>
>>    Dim ab1 As Byte[] = ["33", "48", "49", "50", "51", "52", "53", "54",
>> "55", "56", "57", "65", "66", "67", "68", "69", "70", "71", "72", "73",
>> "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85",
>> "86", "87", "88", "89", "90", "97", "98", "99", "100", "101", "102",
>> "103", "104", "105", "106", "107", "108", "109", "110", "111", "112",
>> "113", "114", "115", "116", "117", "118", "119", "120", "121", "122",
>> "192", "193", "194", "195", "196", "197", "198", "199", "200", "201",
>> "202", "203", "204", "205", "206", "207", "208", "209", "210", "211",
>> "212", "213", "214", "216", "217", "218", "219", "220", "221", "222",
>> "223", "224", "225", "226", "227", "228", "229", "230", "231", "232",
>> "233", "234", "235", "236", "237", "238", "239", "240", "241", "242",
>> "243", "244", "245", "246", "248", "249", "250", "251", "252", "253",
>> "254", "255"]
>>
>>    Dim ab2 As Byte[] = ["95", "48", "49", "50", "51", "52", "53", "54",
>> "55", "56", "57", "65", "66", "67", "68", "69", "70", "71", "72", "73",
>> "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85",
>> "86", "87", "88", "89", "90", "97", "98", "99", "100", "101", "102",
>> "103", "104", "105", "106", "107", "108", "109", "110", "111", "112",
>> "113", "114", "115", "116", "117", "118", "119", "120", "121", "122",
>> "65", "65", "65", "65", "65", "65", "65", "67", "69", "69", "69", "69",
>> "73", "73", "73", "73", "68", "78", "79", "79", "79", "79", "79", "79",
>> "85", "85", "85", "85", "89", "112", "98", "97", "97", "97", "97", "97",
>> "97", "97", "99", "101", "101", "101", "101", "105", "105", "105",
>> "105", "100", "110", "111", "111", "111", "111", "111", "111", "117",
>> "117", "117", "117", "121", "112", "121"]
>>
>>    Dim ab As New Byte[]
>>    Dim b As Byte
>>    Dim o As String
>>    Dim i As Integer
>>
>>    ab = Byte[].FromString(s)
>>
>>    If ab.Count > 0 Then
>>      For Each b In ab
>>        i = ab1.Find(b)
>>        If i > -1 Then
>>          o &= Chr(ab2[i])
>>        Else
>>          o &= "_"
>>        Endif
>>      Next
>>    Endif
>>
>>    Return o
>>
>> End
>>
>> But I am not sure if it is applicable in all cases, e.g. in text strings
>> containing at least one 2-byte character.
>>
>> Martin.
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230216/66c771a5/attachment.htm>


More information about the User mailing list