0

I have a .js file. When I open it in Notepad++ the first two lines look fine like this:

(function(ns, $, undefined){
if(!ns.lang) { ns.lang = {}; }

When I open the file in Intellij it looks like this:

( f u n c t i o n ( n s ,   $ ,   u n d e f i n e d ) { 
 i f ( ! n s . l a n g )   {   n s . l a n g   =   { } ;   } 

It's not visible here. StackOverflow inserts space between nevery character but here is how it looks like in Intellij and in Chrome's inspect(images below). Weird character gets inserted between every code character.

What could be causing this? Notepad++ and Intellij is in UTF-8

enter image description here

enter image description here

isherwood
  • 58,414
  • 16
  • 114
  • 157
  • 1
    looking at it in a hex editor might provide insight – akaphenom Nov 04 '21 at 14:50
  • 1
    Sounds like you have some 0-space Unicode characters throughout the file, where did you get this JS file from? – DBS Nov 04 '21 at 14:51
  • It's written from Java using Files.writeString(). Method says that it's UTF-8 by default –  Nov 04 '21 at 14:52
  • 2
    It looks to me like UCS-2 or UTF16 that is being mis-interpreted/converted incorrectly at some point as UTF8/ASCII – phuzi Nov 04 '21 at 14:54
  • 1
    Could you double check what encoding does Notepad++ think the file is using? – phuzi Nov 04 '21 at 14:55
  • If Java is producing the file, you might want to edit that into the question and tags, that is probably more of a Java question than anything. – coppereyecat Nov 04 '21 at 15:10
  • https://stackoverflow.com/questions/34559993/converting-string-to-utf-8-and-save-it-in-a-file?noredirect=1&lq=1 https://stackoverflow.com/questions/1001540/how-to-write-a-utf-8-file-with-java a couple java threads you might find useful. – coppereyecat Nov 04 '21 at 15:12

0 Answers0