English is not my mother tongue, this page may contain incorrect words or sentences.

urriellu.net => Projects => Software => CharStat

CharStat was written because I wanted to know what were the most common letters in some languages but I didn't find the answer, and... well... I wanted to write some code :-D

It is written in C# and works on Windows by using the implementation of .NET Framework made by Microsoft, and also works on top of Mono 1.2.4, so CharStat should work fine on any OS with a .NET virtual machine installed.

All the useful code is in stats.cs and it is completely isolated from the code used for building the GUI, so it should be easy to port the application to other graphic libraries, to the command line or to a DLL.

Statistics found in this article were generated by CharStat.

Source code

stats.cs, 298 lines      [download]

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.IO;
  6. namespace CharStat_statistics {
  7.     /// <summary>
  8.     /// Class used to generate statistics
  9.     /// </summary>
  10.     public static class stats {
  11.         /// <summary>
  12.         /// Each key is an unicode character found in the text.
  13.         /// Its values are integer variables that determines the amount of times the character appears in the text
  14.         /// </summary>
  15.  
  16. [...]

Program.cs, 16 lines      [download]

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4.  
  5. namespace CharStat_win {
  6.     static class Program {
  7.         /// <summary>
  8.         /// The main entry point for the application.
  9.         /// </summary>
  10.         [STAThread]
  11.         static void Main() {
  12.             Application.EnableVisualStyles();
  13.             Application.SetCompatibleTextRenderingDefault(false);
  14.             Application.Run(new Form1());
  15.         }
  16.     }
  17. }

Form1.cs, 84 lines      [download]

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Collections.Specialized;
  9. using System.IO;
  10. using CharStat_statistics;
  11. namespace CharStat_win {
  12.     public partial class Form1:Form {
  13.         public Form1() {
  14.             InitializeComponent();
  15.  
  16. [...]

Form1.Designer.cs, 260 lines      [download]

  1. namespace CharStat_win {
  2.     partial class Form1 {
  3.         /// <summary>
  4.         /// Required designer variable.
  5.         /// </summary>
  6.         private System.ComponentModel.IContainer components = null;
  7.         /// <summary>
  8.         /// Clean up any resources being used.
  9.         /// </summary>
  10.         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  11.         protected override void Dispose(bool disposing) {
  12.             if(disposing && (components != null)) {
  13.                 components.Dispose();
  14.             }
  15.  
  16. [...]

Screenshots

CharStat running on Windows XPCharStat running on Linux using Mono 1.2.4 

 

Known problems

On Windows if you try to open a file being used by another application an exception will be thrown.

I don't care too much about its problems, it works fine and it doesn't pretend to be a great app, just a fast and simple solution for generating statistics about characters used in a text.

Executable file

Download .exe
It should work (without recompiling) on any OS running a .NET CLR/virtual machine.

CharStat doesn't require installation nor an external library even on Windows, just the .NET Framework, and it's run just by double-clicking on its icon. On KDE/Gnome and any other desktop or GUI-enabled OS it will run if *.exe files are associated to Mono.

Executing from the command line:

$ cd /path/to/the/executable/file
$ mono CharStat-WinForms.exe

I recommend:

$ MONO_THEME=clearlooks mono CharStat-WinForms.exe