예제 #1
0
 def update_fileinfo(cls, fileinfo, document=None):
     try:
         buffer = open(fileinfo.fullpathname, 'rb').read(1024)
         enc = get_encoding(buffer)
         if enc:
             enc = encodingdef.normalize_encname(enc, fileinfo.encoding)
             fileinfo.encoding = enc
     except IOError:
         pass
예제 #2
0
파일: htmlmode.py 프로젝트: kaaedit/kaa
 def update_fileinfo(cls, fileinfo, document=None):
     try:
         buffer = open(fileinfo.fullpathname, 'rb').read(1024)
         enc = get_encoding(buffer)
         if enc:
             enc = encodingdef.normalize_encname(enc,
                                                 fileinfo.encoding)
             fileinfo.encoding = enc
     except IOError:
         pass
예제 #3
0
    def update_fileinfo(cls, fileinfo, document=None):
        if not document:
            try:
                with open(fileinfo.fullpathname, 'rb') as buffer:
                    s = buffer.read(1024)
            except IOError:
                return
        else:
            s = document.gettext(0, 1024).encode('utf-8', errors='ignore')

        m = re.search(rb'@charset\s+(' + rb'"([^"]+)"|' + rb"('[^']+'))", s)
        if m:
            enc = str(m.group(2) or m.group(3), 'utf-8', 'replace').strip()
            enc = encodingdef.normalize_encname(enc, fileinfo.encoding)
            fileinfo.encoding = enc
예제 #4
0
파일: cssmode.py 프로젝트: kaaedit/kaa
    def update_fileinfo(cls, fileinfo, document=None):
        if not document:
            try:
                with open(fileinfo.fullpathname, 'rb') as buffer:
                    s = buffer.read(1024)
            except IOError:
                return
        else:
            s = document.gettext(0, 1024).encode('utf-8', errors='ignore')

        m = re.search(
            rb'@charset\s+(' + rb'"([^"]+)"|' + rb"('[^']+'))", s)
        if m:
            enc = str(m.group(2) or m.group(3), 'utf-8', 'replace').strip()
            enc = encodingdef.normalize_encname(enc, fileinfo.encoding)
            fileinfo.encoding = enc
예제 #5
0
파일: fileio.py 프로젝트: hirokiky/kaa
 def adjust_encoding(self, encoding):
     if encoding.lower() == 'shiftjis':
         return 'cp932'
     encoding = encodingdef.normalize_encname(encoding)
     return encoding