ansi

How to read an ANSI encoded file containing special characters

China☆狼群 提交于 2019-11-28 19:04:26
I'm writing a TFS Checkin policy, which checks if our source files containing our file header. My problem is, that our file header contains a special character "©" and unfortunately some of our source files are encoded in ANSI. So if I read these files in the policy, the string looks like this "Copyright � 2009". string content = File.ReadAllText(pendingChange.LocalItem); I tired to change the encoding of the string, but it does not help. So how can I read these files, that I get the correct string "Copyright © 2009"? Thanks for help! Regards Eny Use Encoding.Default : string content = File

ANSI Color Codes in VIM

本小妞迷上赌 提交于 2019-11-28 17:23:53
问题 I have a script that generates a log file with ANSI color codes in them like so: [2012-05-14 18:00:02] ^[[0mINF: -- Starting update script --^[[0m [2012-05-14 18:00:29] ^[[91mERR: Improper date, entry being ignored.^[[0m Is there any way to get Vim to understand these color codes? Thanks for any help. 回答1: Use Charles Campbell's (Dr Chip) AnsiEsc plugin: http://www.vim.org/scripts/script.php?script_id=302 Before: :AnsiEsc<CR> 回答2: I'm not sure about vim, but if you're just viewing a log file

确定文本文件的编码——乱码探源(2)

孤人 提交于 2019-11-28 14:39:34
在上一篇中,探讨了文件名编码以及非文本文件中的文本内容的编码,在这里,将介绍更为重要的文本文件的编码。 混乱的现状 设想一下,如果在保存文本文件时,也同时把所使用的编码的信息也保存在文件内容里,那么,在再次读取时,确定所使用的编码就容易多了。 很多的非文本文件比如图片文件通常会在文件的头部加上所谓的“magic number(魔法数字)”来作为一种标识。所谓的“magic number”,其实它就是一个或几个固定的字节构成的固定值,用于标识文件的种类(类似于签名)。比如bmp文件通常会以“42 4D”两字节开头。 又比如Java的class文件,则是以四字节的“ca fe ba be”打头。(咖啡宝贝?) 即便没有文件后缀名,根据这些信息也是确定一个文件类型的手段。 附:关于用Notepad++查看十六进制的问题,这是一个插件,如果没有装,菜单--插件--plugin manager--available--HEX-Editor,装上它。装上后,它通常在工具栏的最右边,一个黑色的大写的斜体的“H”就是它。单击它可以在正常文本与16进制间切换。要进一步查看二进制,在文本区,右键--view in--to binary。 没有编码信息 那么,对于文本文件,有没有这样的好事呢?可以简单建立一个文本文件“foo.txt”,里面输入两个简单的字符,比如“hi”,保存,然后再查看文件的大小属性

Struct pointer compatibility

孤街浪徒 提交于 2019-11-28 12:09:28
Suppose we have two structs: typedef struct Struct1 { short a_short; int id; } Struct1; typedef struct Struct2 { short a_short; int id; short another_short; } Struct2; Is it safe to cast from Struct2 * to Struct1 * ? What does the ANSI spec says about this? I know that some compilers have the option to reorder structs fields to optimize memory usage, which might render the two structs incompatible. Is there any way to be sure this code will be valid, regardless of the compiler flag? Thank you! struct pointers types always have the same representation in C. (C99, 6.2.5p27) "All pointers to

Inno Setup Reading file in Ansi and Unicode encoding

梦想的初衷 提交于 2019-11-28 11:36:48
I have a function called GetServerName . I need to pass the file name (say for example 'test.txt') as well as a needed section string (say for example 'server') The test.txt file is contains something like this data1 | abcd data2 | efgh server| 'serverName1' data3 | ijkl I need to extract server name so in my function I will pass something like GetServerName('test.txt', 'server') and it should return serverName1 . My problem is that the test.txt was an ANSI-encoded file earlier. Now it can be an ANSI-encoded file or Unicode-encoded file. Below function worked correctly for ANSI-encoded file,

Colorama for Python, Not returning colored print lines on Windows

a 夏天 提交于 2019-11-28 10:56:33
I've installed colorama for python. I've imported the module as follows: import colorama from colorama import init init() from colorama import Fore, Back, Style print Fore.RED + "My Text is Red" and it returns the ANSI charaters.... esc[31mMy Text is Red This isn`t what I expected. Am I doing something wrong. Thanks. I had this same issue on Windows 7 x64, I finally got the colors working without having to install anything new just by adding the argument convert=True to the init call. from colorama import init, Fore, Back, Style init(convert=True) print(Fore.RED + 'some red text') Sean Lynch I

decimal(s,p) or number(s,p)?

空扰寡人 提交于 2019-11-28 09:46:50
recently, while working on a db2 -> oracle migration project, we came across this situation. the developers were inadvertently creating new table structures using decimal(s,p) columns. I didn't remember Oracle supporting this, but then some digging showed that its a ANSI data type therefore supported by oracle. However, question for me remained - how is this data handled internally ? is there a cost of using ANSI types instead of Oracle's built in types ? Will there be an impact during the data migration if the target type was Oracle built-in type ? Vincent Malgrat In Oracle, they are the same

PHP strtr vs str_replace benchmarking

旧巷老猫 提交于 2019-11-28 09:27:13
问题 I'm curious what the most performant method of doing string transformations is. Given a n input string and a set of translations, what method is the most efficient in general? I currently use strtr() , but have tested various looping methods, str_replace() with an array, etc. The strtr() method benchmarks the fastest on my system, depending on the translations, but I'm curious if there are faster methods I haven't thought of yet. If it's pertinent, my particular use case involves transforming

ANSI-Coloring Console Output with .NET

徘徊边缘 提交于 2019-11-28 09:21:14
I try to generate colored console output using ANSI escape codes with the following minimal C# program: using System; // test.cs class foo { static void Main(string[] args) { Console.WriteLine("\x1b[36mTEST\x1b[0m"); } } I am running Ansicon v1.66 on Windows 7 x64 with csc.exe ( Microsoft (R) Visual C# Compiler version 4.6.0081.0 ). Colored output works fine in this configuration; Ansicon itself is working flawlessly. To cross-check I use a node.js one-liner that is 100% equivalent to the C# program: // test.js console.log("\x1b[36mTEST\x1b[0m"); And, even more basic, a hand-crafted text file:

How to recognize ansi color escape codes in Windows7 64 bit command terminal

只谈情不闲聊 提交于 2019-11-28 04:25:37
问题 I have tried Ansicon and I still cannot get ansi escape sequences to become recognized and interpreted in my CMD.EXE command prompt on Windows 7 64 bit. Has anyone been able to work this correctly and get a colorized console with this OS? 回答1: I ran into the same problem today, and found a workaround. The commandline utility Windows ANSI Color detects ANSI color codes and sets the corresponding console color. Example: myapp.bat | wac where wac is the Windows ANSI color utility 回答2: Ansicon