Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing 0.0.0.0 in front of the last line in the output file #1

Closed
Tinase-nau opened this issue Jan 4, 2024 · 11 comments
Closed

Missing 0.0.0.0 in front of the last line in the output file #1

Tinase-nau opened this issue Jan 4, 2024 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@Tinase-nau
Copy link

Thought to try out hostscompress-x64.exe on StevenBlack's "Unified hosts + gambling + porn" hosts file
Gave it switches /d /i and /o
99% all good until I noticed that the last line in the output file is missing the 0.0.0.0 at front

This is the output from my cmd window:
Reading "C:\[at the end of the rainbow]\hosts" content...
Compiling urls for [0.0.0.0]...
Found urls for [0.0.0.0]; Compressing...
〘
〘█
〘██
[Multiple pages of pyramid shaped pattern repetition until it's just a block]
〘███████████████████████████████████████████████████████████████████████████████〘████████████████████████████████████████████████████████████████████████████████████████████████████〙100%
Compressed [210554] urls to [23394] lines...
Compiling urls for [127.0.0.1]...
No urls found for [127.0.0.1]...
Compressed data has been successfully written to:
"C:\[at the end of the rainbow]\hostsNEW"...

I tried without /d and /i too.

@Tinase-nau Tinase-nau changed the title Missing 0.0.0.0 in front of the last line in output file Missing 0.0.0.0 in front of the last line in the output file Jan 4, 2024
@Lateralus138
Copy link
Owner

Lateralus138 commented Jan 4, 2024

Sorry to hear you are having issues; I have tested extensively in both CMD and Powershell before and have none of these issues, but I will try and help if I can. I just need a little more input from you for the CMD output:

  1. Are you using a non-US locale (don't think this will be the issue, but I will look into it anyway if only to rule it out)?
  2. What's your CMD's code page? This shouldn't matter as the code page should be set via the program anyway, but again I will look into it. Any modern terminal even as far back as the late 2000's/early 2010's should display Unicode characters correctly as long as the environment is set up (as my program does).

The problem with the displayed output is that your terminal is not displaying Unicode characters nor ANSI escaped sequenced output correctly. Since the program is not throwing errors/exceptions this means the code page is being set correctly during the program's runtime.

I'll check out my source code in a few hours for the 0.0.0.0 issue.

Edit: I just tested and you're correct in that the last line does not prepend the 0.0.0.0. Haven't had a chance to look at my source yet though. Give me a little while please. As for the CMD displayed output I can not produce the issue:

hostscompress_cmd_test2

and as for the main issue:

hostscompress_cmd_test

Edit 2: Already found the issue and fixed:

hostscompress_cmd_test3

If you want to test the new version early you can download the attached zip file and test or wait a day or two for me to upload the new version (v1.1.1.*) with the fix (but without a display fix as I don't know what the issue is here):

hostscompress-1.1.1.0.zip

@Lateralus138 Lateralus138 self-assigned this Jan 4, 2024
@Lateralus138 Lateralus138 added the bug Something isn't working label Jan 4, 2024
@Tinase-nau
Copy link
Author

Tinase-nau commented Jan 5, 2024

Ran the new one, the results are better indeed:

> hostscompress /d /i test.txt /o hosts.txt
Reading "C:\[somewhere over the rainbow]\test.txt" content...
Compiling urls for [0.0.0.0]...
Found urls for [0.0.0.0]; Compressing...
〘████████████████████████████████████████████████████████████████████████████████████████████████████〙100%
Compressed [205513] urls to [22834] lines...
Compiling urls for [127.0.0.1]...
No urls found for [127.0.0.1]...
Compressed data has been successfully written to:
"C:\[somewhere over the rainbow]\hosts.txt"...

chcp in cmd returns:

Active code page: 437

Get-WinSystemLocale in PowerShell shows:

LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

Python has no trouble at all showing output in cmd: for e.g., if I test with code

print('░▒▓')

I do get the three shades in my cmd box:

py output

@Lateralus138
Copy link
Owner

Lateralus138 commented Jan 5, 2024

Glad it's working for you! I'm going to officially release the bug fix today or tomorrow, but as for the display issue I'm not sure what I'm going to do yet so I'll keep this issue open.

The progress bar is only there so people have a good idea of how fast it works, but this works so fast compared to my scripts that it's almost not necessary so I may or may not remove it in the next release. As for the main functionality of the program itself it makes no difference.

I think I see the display issue now though. The code page is not being set properly or something in the program. The necessary code page is 65001 (I forgot that I manually set mine via the registry in HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor > Autorun) and so when I was testing the program my tests were redundant, this will either be my next bug fix or removed, not sure yet.

If you're interested in changing your code page via registry you can start your default editor up via [Win Key]+r > type regedit (or search in your Start Menu) and look for the above path and in the Autorun value enter chcp 65001 >NUL 2>NUL. You can also just do this manually in CMD itself.

image

@Tinase-nau
Copy link
Author

With such small amount of data to process the function of keeping the progress bar updated may actually slow down the program.
It would be better to just leave a notice "Please wait a few seconds..."

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      19042  0

@Lateralus138
Copy link
Owner

Lateralus138 commented Jan 5, 2024

It's still fast no matter what, but I know you're right to a point. Trivial slow down though. I edited the above message if you're interested. It's early in the morning and I'm tired so I jumped the gun on my original reply.

@Tinase-nau
Copy link
Author

If it's not enabled by default by Microsoft it's best to keep your system in standard configuration so your developed applications would be compatible with as many clients as possible. :)

@Lateralus138
Copy link
Owner

I know, but I don't always like default crap for my main machines and I don't always do tests locally, lots of times it's in a CI nowadays, but I wrote this program for myself originally and wasn't worried about other users at the time as I didn't think I was going to release it. The only reason I released it is because I seen so many people having issues on Steven's hosts repo that I thought I'd help. I've been programming 30+ years, so I'm well aware of how the crappy environment of the Windows and its registry works lol. I don't even need to release this for Linux because it's not necessary over there lol.

@Tinase-nau
Copy link
Author

Tinase-nau commented Jan 5, 2024

Since StevenBlack specifically mentions your tool for hosts compression in hosts repo README I wanted to make sure it works. :)

Since the problems are solved this issue can be closed, or close after you upload the final fixed version under Releases.

@Lateralus138
Copy link
Owner

Yep, I wrote that paragraph :D.

Lateralus138 added a commit that referenced this issue Jan 5, 2024
Lateralus138 added a commit that referenced this issue Jan 5, 2024
@Lateralus138
Copy link
Owner

Official 1.1.1.0 version with this bug fix (for prepended IP only) has been released: 1.1.1.0

@Lateralus138
Copy link
Owner

Version 2 has been officially released and removes the progress bar if anyone is interested. https://github.com/Lateralus138/hosts-compress-windows/releases/tag/2.0.0.1709747905001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants