Adding Unicode operators to D

Steven Schveighoffer schveiguy at yahoo.com
Fri Oct 24 21:44:35 PDT 2008


"Bill Baxter" wrote
> On Sat, Oct 25, 2008 at 1:33 PM, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>> "Benji Smith" wrote
>>> Bill Baxter wrote:
>>>> On Sat, Oct 25, 2008 at 10:31 AM, Benji Smith 
>>>> <dlanguage at benjismith.net>
>>>> wrote:
>>>>> Yigal Chripun wrote:
>>>>>> Bill Baxter wrote:
>>>>>>> On Sat, Oct 25, 2008 at 9:15 AM, Sergey Gromov 
>>>>>>> <snake.scaly at gmail.com>
>>>>>>> wrote:
>>>>>>>> Sat, 25 Oct 2008 06:43:19 +0900,
>>>>>>>> Bill Baxter wrote:
>>>>>>>>> On Sat, Oct 25, 2008 at 6:37 AM, ore-sama <spam at here.lot> wrote:
>>>>>>>>>> Bill Baxter Wrote:
>>>>>>>>>>
>>>>>>>>>>> (like I haven't been able to figure out how to get the
>>>>>>>>>>> DOS console in Windows to display UTF-8)
>>>>>>>>>> Console is a legacy technology (you even still call it "DOS"), 
>>>>>>>>>> why
>>>>>>>>>> expect features from it?
>>>>>>>>> So tell me what the alternative is?  I had trouble with running D
>>>>>>>>> tools from a Cygwin shell.  Can't remember if I tried MSYS or not.
>>>>>>>>>
>>>>>>>>> Anyone using a shell for Windows that works and supports UTF-8
>>>>>>>>> properly?
>>>>>>>> A regular Windows console supports UTF-8 to some extent:
>>>>>>>>
>>>>>>>> * Change console font to Lucida Console
>>>>>>>> * issue "chcp 65001"
>>>>>>>>
>>>>>>>> You can even get more fonts into there with a bit of hackery.
>>>>>>> I did that but "type <filewith-utf8.txt>"  still prints garbage.
>>>>>>>
>>>>>>> --bb
>>>>>> so don't use type. use notepad instead...
>>>>>> notepad <filewith-utf8.txt>
>>>>>> also, MSYS gives you all the linux tools if you really need to be 
>>>>>> shell
>>>>>> only.
>>>>>> last resort: nothing stops you from implementing your own "cat"
>>>>>> application in D with full Unicode support.
>>>>>>
>>>>>> most if not all linux shell tools are separate executables anyway and
>>>>>> if
>>>>>> any still do not support unicode it'll be trivial to roll your own
>>>>>> replacements for the bad ones.
>>>>> Oh, and one of my favorite tricks in Windows is to install cygwin
>>>>> (usually
>>>>> at "C:\cygwin" or whatever their boneheaded installer insists on 
>>>>> using)
>>>>> and
>>>>> then add the bin path ("C:\cygwin\bin") to the windows PATH.
>>>>>
>>>>> That way, I can continue using the ordinary windows shell (which I
>>>>> prefer,
>>>>> since it doesn't force me to use the nutty directory names that the
>>>>> cygwin
>>>>> shell uses), but I can still access all the linux commands.
>>>>>
>>>>> Calling grep from a windows shell is the bestest!
>>>>
>>>> But that has the same problem.  Cygtools don't understand windows
>>>> paths so barf when you say "grep c:\foo.txt"  But the Windows shell
>>>> only will only autocomplete Windows-style paths.
>>>>
>>>> I've found the gnuwin32 tools to work a little better on that front.
>>>>
>>>> --bb
>>>
>>> Wha???
>>>
>>> The "grep" tool doesn't read the path. The *shell* interprets the path 
>>> and
>>> passes the text to the program. That's how all the gnu tools are able to
>>> pipe their results from one tool to the other.
>>>
>>> Or at least, that's how I assume it works.
>>
>> No, grep accepts either input.  The shell does not change paths to 
>> windows
>> style, that is what cygpath is for.  But it does interpret backslashes, 
>> so
>> you have to double all those.
>>
>> So for instance, in a cygwin shell, this works also:
>>
>> grep -i "SHAZZAM" C:\\Documents\ and\ Settings\\benji\\Desktop\\my\
>> filename\ with\ spaces.txt
>>
>> The arguments are passed as they are, grep just is smart enough to use
>> either one.  Probably many tools are that way, I wouldn't know because I
>> usually do the /cygdrive/c/... form.
>>
>>> The key is to never never never use the cygwin shell. It's a piece of
>>> garbage. But using the executables from the "cygwin\bin" directory 
>>> within
>>> the windows shell... Priceless!
>>
>> Without the cygwin shell, you lose all bash features, like for, or 
>> backticks
>> to execute a command and use it's output.  The paths are a minor 
>> annoyance
>> IMO.  Using the cmd.exe shell is ok for simple tasks, but it pales 
>> severely
>> in comparison to the power of bash.
>>
>> So piece of garbage it is not.  Something you don't understand how to use
>> properly? definitely ;)
>
> Yeh, I love the bash shell.  Really the only thing keeping me from
> using it for D work is the fact that it won't auto-complete Windows
> filenames.

It's ugly, but can be aliased or scripted, look into cygpath:

cygpath -w /cygdrive/c/filename.txt
outputs:

C:\filename.txt

so you can use dmd combined with cygpath:

dmd `cygpath -w /cygdrive/c/path/to/d/files/*.d`

It wouldn't take much to write a bash script to do this for you...

-Steve 




More information about the Digitalmars-d-announce mailing list