kimlimjustin / xplorer

Xplorer, a customizable, modern file manager

Home Page:https://xplorer.space/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cyrillic characters not shown correctly

Nord1cWarr1or opened this issue · comments

Cyrillic characters not shown correctly

image

  • OS Version: Windows 10 Pro 21H1, build 19043.1237
  • App Version: 0.1.0
commented

Wait, what does Cyrillic mean?

Wait, what does Cyrillic mean?

Russian alphabet

commented

I think this is a problem because it is implemented via the child process (

Constants.WINDOWS_COMMAND = 'wmic logicaldisk get Caption,FreeSpace,Size,VolumeName,Description /format:list';
).

Thanks for the report tho, I'll try to fix it

commented

hello guys, instead of doing a copy of node-disk-info code why not using package.json to have it as a dependency ?
A lot of bug have been solved and unless you copy the corrected source code again you won't be able to have the fix and you won't be warned that a new version have been released.
Also there is no versioning available in your Lib folder so nobody know if the code has already been fixed in the source or not.

Yep, I'm fixing it rn. The module had a bug at that time and I decided to copy the code to fix it by myself and also some additional features and forgot about it hehe. I'm fixing it rn, will deliver a fix soon!

Also, node-disk-info does not support volumename parsing, and this error is because volumename tho...

Can't find any solutions right now, I tried the GetVolumeInformationA, marking this issue as help wanted, any PR will be appreciated

commented

I remember I had to use this to find the encoding used by the PC and return it as a UTF-8 buffer which after I can change for a string.
Have you try to copy node-disk-info and just add volumename on it ?

        const drives: Drive[] = [];
        let buffer = Utils.execute(Constants.WINDOWS_COMMAND);
        
        const cp = Utils.chcp();
        let encoding = '';
        switch (cp) {
            case '65000': // UTF-7
                encoding = 'UTF-7';
                break;
            case '65001': // UTF-8
                encoding = 'UTF-8';
                break;   
            default: // Other Encoding
                if (/^-?[\d.]+(?:e-?\d+)?$/.test(cp)) {
                    encoding = 'cp' + cp;
                } else {
                    encoding = cp;
                }
        }
        buffer = iconv.encode(iconv.decode(buffer, encoding),'UTF-8');

        const lines = buffer.toString().split('\r\r\n');

On my Japanese PC I can show the volume name in Japanese without trouble.

Filesystem: Removable Disk
Blocks: 8036257792
Used: 20480
Available: 8036237312
Capacity: 0%
Mounted: D:
Name: データ

(this is the output of a modified node-disk-info example command.

@Ekristoffe I'm sorry but do you have an example of it?

This time I've tried the latest version of node-disk-info by installing via yarn and edit it inside node_modules and what I got on my computer is ??? instead of データ
image

This is what I've tried

diff --git a/node_modules/node-disk-info/dist/classes/drive.d.ts b/node_modules/node-disk-info/dist/classes/drive.d.ts
index 79e7add..e47c7eb 100644
--- a/node_modules/node-disk-info/dist/classes/drive.d.ts
+++ b/node_modules/node-disk-info/dist/classes/drive.d.ts
@@ -28,6 +28,7 @@ export default class Drive {
      * Indicates the mount point of the disk.
      */
     private readonly _mounted;
+    private readonly _volumename;
     /**
      * Constructor for Drive class.
      *
@@ -38,7 +39,7 @@ export default class Drive {
      * @param {string} capacity Disk capacity.
      * @param {string} mounted Indicates the mount point of the disk.
      */
-    constructor(filesystem: string, blocks: number, used: number, available: number, capacity: string, mounted: string);
+    constructor(filesystem: string, blocks: number, used: number, available: number, capacity: string, mounted: string, volumename:string);
     /**
      * Drive filesystem.
      *
@@ -75,4 +76,5 @@ export default class Drive {
      * @return Gets the mount point of the disk.
      */
     get mounted(): string;
+    get volumename(): string;
 }
diff --git a/node_modules/node-disk-info/dist/classes/drive.js b/node_modules/node-disk-info/dist/classes/drive.js
index 9d13d32..7f4dcfb 100644
--- a/node_modules/node-disk-info/dist/classes/drive.js
+++ b/node_modules/node-disk-info/dist/classes/drive.js
@@ -16,13 +16,14 @@ var Drive = /** @class */ (function () {
      * @param {string} capacity Disk capacity.
      * @param {string} mounted Indicates the mount point of the disk.
      */
-    function Drive(filesystem, blocks, used, available, capacity, mounted) {
+    function Drive(filesystem, blocks, used, available, capacity, mounted, volumename=null) {
         this._filesystem = filesystem;
         this._blocks = blocks;
         this._used = used;
         this._available = available;
         this._capacity = capacity;
         this._mounted = mounted;
+        this._volumename = volumename
     }
     Object.defineProperty(Drive.prototype, "filesystem", {
         /**
@@ -96,6 +97,18 @@ var Drive = /** @class */ (function () {
         enumerable: false,
         configurable: true
     });
+    Object.defineProperty(Drive.prototype, "volumename", {
+        /**
+         * Indicates the mount point of the disk.
+         *
+         * @return Gets the mount point of the disk.
+         */
+        get: function () {
+            return this._volumename;
+        },
+        enumerable: false,
+        configurable: true
+    });
     return Drive;
 }());
 exports.default = Drive;
diff --git a/node_modules/node-disk-info/dist/platforms/windows.js b/node_modules/node-disk-info/dist/platforms/windows.js
index 303bd1d..6762154 100644
--- a/node_modules/node-disk-info/dist/platforms/windows.js
+++ b/node_modules/node-disk-info/dist/platforms/windows.js
@@ -41,11 +41,13 @@ var Windows = /** @class */ (function () {
         }
         buffer = iconv_lite_1.default.encode(iconv_lite_1.default.decode(buffer, encoding), 'UTF-8');
         var lines = buffer.toString().split('\r\r\n');
+        console.log(lines)
         var newDiskIteration = false;
         var caption = '';
         var description = '';
         var freeSpace = 0;
         var size = 0;
+        var volumename = ''
         lines.forEach(function (value) {
             if (value !== '') {
                 var tokens = value.split('=');
@@ -65,6 +67,9 @@ var Windows = /** @class */ (function () {
                     case 'Size':
                         size = isNaN(parseFloat(data)) ? 0 : +data;
                         break;
+                    case 'VolumeName':
+                        volumename = data;
+                        break;
                 }
             }
             else {
@@ -74,7 +79,7 @@ var Windows = /** @class */ (function () {
                     if (size > 0) {
                         percent = Math.round((used / size) * 100) + '%';
                     }
-                    var d = new drive_1.default(description, size, used, freeSpace, percent, caption);
+                    var d = new drive_1.default(description, size, used, freeSpace, percent, caption, volumename);
                     drives.push(d);
                     newDiskIteration = false;
                     caption = '';
diff --git a/node_modules/node-disk-info/dist/utils/constants.js b/node_modules/node-disk-info/dist/utils/constants.js
index d2936e1..52b0d4c 100644
--- a/node_modules/node-disk-info/dist/utils/constants.js
+++ b/node_modules/node-disk-info/dist/utils/constants.js
@@ -10,7 +10,7 @@ var Constants = /** @class */ (function () {
     /**
      * Command to execute on Windows.
      */
-    Constants.WINDOWS_COMMAND = 'wmic logicaldisk get Caption,FreeSpace,Size,VolumeSerialNumber,Description  /format:list';
+    Constants.WINDOWS_COMMAND = 'wmic logicaldisk get Caption,FreeSpace,Size,VolumeSerialNumber,Description,VolumeName  /format:list';
     /**
      * Command to execute on Linux.
      */

Also, if you could please support this directly from node-disk-info, it would be much helpful.

Sorry for keep disturbing you.

Thanks and Regards

commented

Hello I have published my changes on this:
https://github.com/Ekristoffe/node-disk-info/tree/TestName
It is a quick and dirty test so only windows system and the names could be better

image
@Ekristoffe It shows ??? too while this is the real name:
image

Is it because my system is incompatible (but I don't think so, I got an i7 with 32GB of ram)

Or @Nord1cWarr1or could you please give it a try?

commented

what is the output of the command (in cmd):
chcp
wmic logicaldisk get Caption,VolumeName /format:list
thanks.

what is the output of the command (in cmd): chcp wmic logicaldisk get Caption,VolumeName /format:list thanks.

chcp

Active code 65001

wmic logicaldisk get Caption,VolumeName /format:list

Caption=C:
VolumeName=Windows 10


Caption=D:
VolumeName=System Reserved


Caption=E:
VolumeName=Program


Caption=F:
VolumeName=Data


Caption=G:
VolumeName=OS


Caption=H:
VolumeName=New Volume


Caption=I:
VolumeName=??
commented

Indeed your pc can't handle the non latin char it seem (i think it is more a windows problem since linux is always using UTF8) ...
I am interested by @Nord1cWarr1or could you also try the chcp and wmic command ?

@Ekristoffe, yes.
chcp

Текущая кодовая страница: 866 

wmic logicaldisk get Caption,VolumeName /format:list

Caption=C:
VolumeName=


Caption=D:
VolumeName=Зарезервировано системой


Caption=E:
VolumeName=


Caption=F:
VolumeName=


Caption=H:
VolumeName=Новый том
commented

Hello, The fix should work without any problem as long as windows is using the right codepage.

Erm, it's probably my computer problem (but I am sure there're many people with the same problem as me),

I think I'll commit the volume name feat here to support those people like @Nord1cWarr1or .

The code will first check if the volumename property is valid (not ???), if it's valid, the code will display the volumename, otherwise display the filesystem.

Maybe this is the best approach for now.

I'll open a PR for this issue soon later (as soon as I can use my computer), will you be able to help me test(review) it? @Nord1cWarr1or or @Ekristoffe

Thanks and best regards

I'll open a PR for this issue soon later (as soon as I can use my computer), will you be able to help me test(review) it? @Nord1cWarr1or or @Ekristoffe

Sure. Test build will be at Actions, right?

I'll open a PR for this issue soon later (as soon as I can use my computer), will you be able to help me test(review) it? @Nord1cWarr1or or @Ekristoffe

Sure. Test build will be at Actions, right?

No, I mean could you please try to pull the utf8_branch and build it from the source (you'll need to install VS C++ tho) and see if it works?

commented

I think I have some code for this. Get Git for the cloning process and you know how to build it after that.

$ git clone https://github.com/kimlimjustin/xplorer.git
$ git checkout utf8_branch

Then you can start the build process.
Edit: Works on all OSes, you need the programs basically.

No, I mean could you please try to pull the utf8_branch and build it from the source (you'll need to install VS C++ tho) and see if it works?

Sorry, but I don't know anything about programming.
But if you can make a guide for me, how to build this project, then maybe I can test it.

No, I mean could you please try to pull the utf8_branch and build it from the source (you'll need to install VS C++ tho) and see if it works?

Sorry, but I don't know anything about programming. But if you can make a guide for me, how to build this project, then maybe I can test it.

Ah, I see. However, here's a link to the executable I built, could you please give it a try? https://drive.google.com/file/d/1luqSBsbkD5yE1l-zkI1efB9Tl0HqIuh5/view?usp=sharing

@kimlimjustin I just installed it, and it works as expected.

image

Glad to here it, merging the branch into master

fixed via #144