Search found 4596 matches

by aGerman
24 Aug 2025 14:53
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

I could have sworn that I tested it :roll: Fixed. A minor update is that it now uses a US as delimiter. It's nowhere used anymore. However, we meet its original semantics if we take it for this purpose. Perhaps this is something that jeb feels more comfortable with. The downside is that the macro in...
by aGerman
24 Aug 2025 13:30
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

I was referring more to why MS didn't implement it when they refactored Batch with the release of NT. There's no hope of something like that happening again in the future, as they've gone in a new direction with PowerShell (almost two decades ago already). https://github.com/microsoft/terminal/blob/...
by aGerman
24 Aug 2025 06:00
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

I have a feeling my demonstration that measured length is not a good basis for making assumptions about displayed width has left you in paralysis :lol: In this case - don't worry, you just know now that the two are not connected. However, it will still work for printable ASCII, box drawing and block...
by aGerman
22 Aug 2025 16:00
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

our general default test string Huh? Did we really define that? :lol: However, I actually still have something like that in my test case. :: make sure we are in the spotlight: @if "%~1"=="" start /realtime conhost "%~f0" 1&exit /b @echo off &setlocal DisableDelayedExpansion :: 33 set "str0=&<>|^-+*...
by aGerman
22 Aug 2025 11:11
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

I absolutely get your point, jeb. And if you would've asked me a decade ago, my answer was pretty much the same as yours. However, it's a fact that we can't meet the expectation of a user who only relies on what the macro name suggests. Not only because we are technically unable to do that. Also bec...
by aGerman
20 Aug 2025 15:30
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

pieh-ejdsch What if we claim (or define) that control characters are not part of a string? Would that be reasonable? :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :initStrLen :: Computes the number of resulting UTF-16 code units in a string. :: %strLen% str [len] :...
by aGerman
19 Aug 2025 10:12
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

This is now unbelievably fast. Kudos! However, I admit that I immediately changed the code to get rid of the variables i and o, as they seemed like code obfuscation :lol: Talking of obfuscation - is there any good reason to prefer ... for /f tokens^=15delims^=^ %%3 ... ... to the more readable ... f...
by aGerman
17 Aug 2025 04:04
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

Hmm, the new code performs slightly worse in my tests. Expanding !%%1:~4095,1! twice might be the reason, although it's a clever way to handle a space at this position.
by aGerman
13 Aug 2025 16:19
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

I'm still trying to address other given feedback without performance impact. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :initStrLen :: Computes the number of resulting UTF-16 code units in a string. :: %strLen% str [len] :: str - [ByRef In] Name of the variable ...
by aGerman
13 Aug 2025 12:20
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

This is so impressive :!:

BTW Was this known to work?

Code: Select all

if not defined %%1 (if %%? lss ' endlocal)^&(set /a %%2=0) else^
This would have been my expectation:

Code: Select all

if not defined %%1 ((if %%? lss ' endlocal)^&set /a %%2=0) else^
by aGerman
11 Aug 2025 14:56
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

So, we define that delayed expansion is enabled but the cmd may gives us the finger :lol:
Like if I go to a hardware store to buy an 8mm nut, but the shop assistant decides that I only get one if I can show the matching screw :roll:
Got it. Thanks!
by aGerman
11 Aug 2025 13:23
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

Yes, of course, I fully understand why it works ... not 🤪🥴
I get why you use !=! since this can't ever be a defined variable. However what puzzles me is why it even makes any difference if it comes before the caret (or after it, as this seems to work too).
Anyway, I just accept it :lol:

Steffen
by aGerman
10 Aug 2025 08:06
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

I would never have thought of that :lol:
FWIW You could also update this in your previous codes. When you're logged in, you'll see an edit button (pencil) at the top of each of your posts. (Although it doesn't matter if not. The content of the strLen macro is not affected, only its initialization.)
by aGerman
08 Aug 2025 14:11
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

Your HEX magic is incredible :lol: Also for short strings it's now only negligibly slower. The performance gain for longer string is remarkable though. That's how I'm going to save it into my tool collection: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :initStrLe...
by aGerman
06 Aug 2025 10:05
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 91
Views: 212611

Re: strLen boosted

but I assumed there were no quotes for the variable That's a fair assumption. We can just remark it in the macro description as this is our contract with the user :wink: I hadn't noticed the reduction with "FOR %%H IN (FEDCBA9876543210)" Everything that comes before the "set StrLen=..." will not be...