Posted by jpluimers on 2013/06/11
A while ago, I needed to export pure ASCII text from a .NET app.
An important step there is to convert the diacritics to “normal” ASCII characters. That turned out to be enough for this case.
This is the code I used which is based on Extension Methods and this trick from Blair Conrad:
The approach uses String.Normalize to split the input string into constituent glyphs (basically separating the “base” characters from the diacritics) and then scans the result and retains only the base characters. It’s just a little complicated, but really you’re looking at a complicated problem.
Example code:
using System;
using System.Text;
using System.Globalization;
namespace StringToAsciiConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string unicode = "áìôüç";
string ascii = unicode.ToAscii();
Console.WriteLine("Unicode\t{0}", unicode);
Console.WriteLine("ASCII\t{0}", ascii);
}
}
public static class StringExtensions
{
public static string ToAscii(this string value)
{
return RemoveDiacritics(value);
}
// http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net
private static string RemoveDiacritics(this string value)
{
string valueFormD = value.Normalize(NormalizationForm.FormD);
StringBuilder stringBuilder = new StringBuilder();
foreach (System.Char item in valueFormD)
{
UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(item);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(item);
}
}
return (stringBuilder.ToString().Normalize(NormalizationForm.FormC));
}
}
}
–jeroen
Posted in .NET, .NET 3.5, .NET 4.0, .NET 4.5, ASCII, C#, C# 3.0, C# 4.0, C# 5.0, Development, Encoding, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2013/06/07
A while ago (actually, almost two years ago <g>), Chinese Sausage wrote the below answer; it’s on my research list to see if I can stream out my audio library:
Re: Best format to encode into?
« Reply #2 on: 2011-08-14, 14:50:18 »
When space drive IS a concern, then ogg (aoTuV version) is the best format quality-wise (to these ears), as it is more true to the original music source, and it leaves less noticeable noise artifacts than the other encoders. However, aac is almost just as good and also more compatible with mobile phones, iPod’s and other external players, so it is probably a better choice if you want to share your music files with anybody who is not computer savvy. The main thing I do not like about aac (at least HE-AAC) is that it does not support gapless playback, which is particularly annoying if you listen to live albums, or other music which has continuous playback.
At 64kbps though, there is none better than ogg aoTuV. Here is a link to the latest version, in case you want it.
Just replace the ogg.dll and vorbis.dll files to the existing ones in your encoding program (I use MediaMonkey to encode files to ogg).
Hope this helps!
--jeroen
via: Best format to encode into?.
Posted in BASS.NET, Development, Media Streaming, Power User, Software Development, Un4seen BASS Audio Library | Tagged: 2 | Leave a Comment »
Posted by jpluimers on 2013/06/06
About 3 years old (it was at Devoxx 2009), but still a great talk at Parleys.com: Craftsmanship and Policy Presentation by Robert C. Martin.
It was announced as:
Is management ready for the tsunami of professionalism that’s on the horizon?
Enjoy this inspiring and enthusiastic Devoxx keynote by Uncle Bob.
–jeroen
Posted in Development, Software Development | Leave a Comment »
Posted by jpluimers on 2013/06/05
AACPlus allows for a many combinations of encoding flags.
Finding out whick allows to encode a mono audio stream is a bit time consuming.
Luckily, I found this post:
If you want encode in mono make this:
enc_aacPlus test.wav test.aac --br (max 256000) --mono
or for streaming:
enc_aacplus - - --br (max 256000) --silent --rawpcm 44100 2 16 --mono
Note that the various versions of enc_aacPlus.exe requires the enc_aacPlus.dll from WinAmp.
--jeroen
via: AACPlus v2 Encoder Problem..
Posted in BASS.NET, Batch-Files, Development, Media Streaming, Power User, Scripting, Software Development, Un4seen BASS Audio Library | Leave a Comment »
Posted by jpluimers on 2013/06/04
Things That Turbo Pascal is Smaller Than.
Well basically anything.
About 30k was the size our complete IDE in the 80s century.
(Thanks @pstalenh and @rand)
–jeroen
Posted in Delphi, Development, Pascal, Software Development, Turbo Pascal | 4 Comments »
Posted by jpluimers on 2013/05/29
In pre-Galileo versions of Delphi it was easy to run a .BAT or .CMD file as a main project file: just press F9.
Thanks to iManBiglary for posting how to do this in modern Delphi versions. Paraphrased:
Add the file path to cmd.exe (easieist is to add $(ComSpec) which expands the %ComSpec% environment variable) in the tools menu, with /c$EDNAME as the parameter.
In addition, you can tell the IDE to save your file before running the external tool with the $SAVE macro
One of the things you can do with this is add a project containing a batch file that starts to assemble your build results to create a deployment set.
–jeroen
via: Run batch file from Delphi IDE – Stack Overflow.
Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | Leave a Comment »